-
Notifications
You must be signed in to change notification settings - Fork 32
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
A terminal that doesn't match specific strings #123
Labels
Comments
Word |
aha! Again, much appreciated; I understand now what I was doing wrong. Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd like to define a terminal that matches words except specific words.
This is why: trying this code
fails, expectedly, with
Can't disambiguate between: <IdentifierWord(The)> or <The(The)>
, becauseIdentifierWord
matches everything. So what I'd like to do is haveIdentifierWord
not match certain things, such as "the" and "a". However, when I try this, by changing the definition of theIdentifierWord
terminal toIdentifierWord: /(?!The|a)\w+/;
so that it uses a negative lookahead to exclude certain words from matching, then the above code fails withError at 2:4:"\nThe **> apple is a" => Expected: IdentifierWord but found <A(a)>
I don't understand why this is. It's finding the "a" at the beginning of "apple" and treating it as an "a". I don't know if I'm solving this the best way; is there some other way I should be structuring this sort of grammar, or maybe some better way of defining a terminal that matches all words except certain ones?
The text was updated successfully, but these errors were encountered: