nearley icon indicating copy to clipboard operation
nearley copied to clipboard

Can I specify precedence?

Open mspoulsen opened this issue 5 years ago • 1 comments

Say I have an ambiguous grammar like:

main -> (ab | a | b):*
ab -> "ab"
a -> "a"
b -> "b"

Here "ab" can be interpreted as both "ab" or an "a" followed by a "b".

Is there a way to specify precedence in those situations? For example tell nearley that it should prefer "ab" over "a" followed by "b".

Or do I need to use Moo for that?

Thanks!

mspoulsen avatar May 05 '20 07:05 mspoulsen

This is a situation where you should use moo to tokenize and disambiguate.

kach avatar May 06 '20 16:05 kach