New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rnc2rng failure #3

Open
mildred opened this Issue Nov 20, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@mildred

mildred commented Nov 20, 2015

I have the following rnc schema:

namespace xsd = "http://www.w3.org/2001/XMLSchema"

grammar {
    start = element svn {
        # Path to the svn dump file
        attribute dump-file { xsd:string }?,

        # Content of the .SVNAccessFile inline in the XML
        element access-file { xsd:string }?

        # E-mail subscriptions
        & element notification {
            attribute path { xsd:string },
            attribute emails { xsd:string }
        }*
    }
}

Running rnc2rng version 2.0 yields:

Traceback (most recent call last):
  File "/bin/rnc2rng", line 9, in <module>
    load_entry_point('rnc2rng==2.0', 'console_scripts', 'rnc2rng')()
  File "/usr/lib/python3.5/site-packages/rnc2rng/__main__.py", line 9, in main
    xml = serializer.XMLSerializer().toxml(parser.parse(input))
  File "/usr/lib/python3.5/site-packages/rnc2rng/parser.py", line 390, in parse
    return parser.parse(lex(src), state=State())
  File "/usr/lib/python3.5/site-packages/rply/parser.py", line 62, in parse
    self.error_handler(state, lookahead)
  File "/usr/lib/python3.5/site-packages/rnc2rng/parser.py", line 375, in error
    raise Exception(s, t)
Exception: (<rnc2rng.parser.State object at 0x7f78692afa20>, Token('LBRACE', '{'))

I believe my rnc file is correct (but I can't be so sure because I cannot find a converter that would work). If the rnc file is incorrect, I would at least expect a better error message.

@djc

This comment has been minimized.

Show comment
Hide comment
@djc

djc Nov 20, 2015

Owner

According to my reading of the spec, this is not a valid grammar. You should probably get rid of the top-level grammar { } wrapper.

Yeah, error messages aren't that great yet.

Owner

djc commented Nov 20, 2015

According to my reading of the spec, this is not a valid grammar. You should probably get rid of the top-level grammar { } wrapper.

Yeah, error messages aren't that great yet.

@djc

This comment has been minimized.

Show comment
Hide comment
@djc

djc Nov 21, 2015

Owner

Error messages have been improved in 6682abb. Closing.

Owner

djc commented Nov 21, 2015

Error messages have been improved in 6682abb. Closing.

@djc djc closed this Nov 21, 2015

@mthuurne

This comment has been minimized.

Show comment
Hide comment
@mthuurne

mthuurne Jul 9, 2018

I think the top-level grammar { } is valid: there is a rule that produces it via the pattern nonterminal in section 2 of the spec (second to last entry).

Also "grammar" is in the list of keywords in the spec, but not in rnc2rng's parser.py. Other missing keywords are "external", "inherit" and "token".

I ran into this problem when trying to convert the schemas from the Nu Html Checker, for example this one.

mthuurne commented Jul 9, 2018

I think the top-level grammar { } is valid: there is a rule that produces it via the pattern nonterminal in section 2 of the spec (second to last entry).

Also "grammar" is in the list of keywords in the spec, but not in rnc2rng's parser.py. Other missing keywords are "external", "inherit" and "token".

I ran into this problem when trying to convert the schemas from the Nu Html Checker, for example this one.

@djc

This comment has been minimized.

Show comment
Hide comment
@djc

djc Jul 9, 2018

Owner

Hmm, okay. So I interpreted the "single element" constraint for pattern in topLevelBody as, it should be an element primary, but that interpretation appears to be too narrow.

I've started to extend the grammar to allow it to eventually deal with the SVG spec (that's certainly the largest schema I've thrown at rnc2rng so far!), but it looks like it might take some further work.

Owner

djc commented Jul 9, 2018

Hmm, okay. So I interpreted the "single element" constraint for pattern in topLevelBody as, it should be an element primary, but that interpretation appears to be too narrow.

I've started to extend the grammar to allow it to eventually deal with the SVG spec (that's certainly the largest schema I've thrown at rnc2rng so far!), but it looks like it might take some further work.

@djc djc reopened this Jul 9, 2018

djc added a commit that referenced this issue Jul 23, 2018

@djc

This comment has been minimized.

Show comment
Hide comment
@djc

djc Jul 23, 2018

Owner

@mthuurne so current rnc2rng master can parse a lot more of the SVG spec from the validator repo you pointed to (and also the original schema that started this issue). However, it's currently failing when trying to parse svg-extensibility.rnc. As far as I can tell, the use of annotation elements here is invalid per the spec. The spec says that a top-level annotation must always be surrounded by square brackets, and so an annotation element like a:documentation cannot appear at the start of an RNC file like it does here.

Do you disagree with my interpretation of the spec?

Owner

djc commented Jul 23, 2018

@mthuurne so current rnc2rng master can parse a lot more of the SVG spec from the validator repo you pointed to (and also the original schema that started this issue). However, it's currently failing when trying to parse svg-extensibility.rnc. As far as I can tell, the use of annotation elements here is invalid per the spec. The spec says that a top-level annotation must always be surrounded by square brackets, and so an annotation element like a:documentation cannot appear at the start of an RNC file like it does here.

Do you disagree with my interpretation of the spec?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment