Skip to content
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

Spurious parses stemming from nullable nonterminals #85

Closed
corwin-of-amber opened this issue Jan 22, 2016 · 2 comments
Closed

Spurious parses stemming from nullable nonterminals #85

corwin-of-amber opened this issue Jan 22, 2016 · 2 comments
Labels

Comments

@corwin-of-amber
Copy link
Contributor

The following grammar:

@builtin "whitespace.ne"

d -> a

a -> b _ "&"
   | b

b -> letter
   | "(" _ d _ ")"

letter -> [a-z]

when run using nearley-test on (x), generates two (identical) parses [ [ [ '(', null, [ [ [ [ 'x' ] ] ] ], null, ')' ] ] ]. Since the above grammar is unambiguous, this is unexpected.

Notice that this does not occur if you omit the rule a -> b _ "&", which does not appear in the derivation, and this is even more unexpected. It has to do with the order of prediction.

I am preparing a pull request that suggests a fix.

corwin-of-amber added a commit to corwin-of-amber/nearley that referenced this issue Jan 22, 2016
in an unambiguous grammar in some situation involving nullable nonterminals
(issue kach#85).
@kach kach added the bug label Jan 23, 2016
@corwin-of-amber
Copy link
Contributor Author

Tried 2.2.0 and it works 👍

@kach
Copy link
Owner

kach commented Jan 25, 2016

Awesome. Closing, then.

@kach kach closed this as completed Jan 25, 2016
kach pushed a commit that referenced this issue Feb 4, 2016
in an unambiguous grammar in some situation involving nullable nonterminals
(issue #85).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants