-
Notifications
You must be signed in to change notification settings - Fork 419
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
Confusing error message for failed positive lookahead expression #640
Comments
Hi, I'm not very good at It seems like what you're saying is "I have a rule where Is that roughly correct? |
I would rather say: "I have a rule where |
Oh, the error message is confusing because the forbiddance is a repetition? |
I would say the message is confusing because
Maybe it would be useful to mention lookahead expressions if they are the cause of failure. Forbidden repetitions are just a case, compare this without a forbidden repetition. const pegResult = require('pegjs/')
.generate('root = ("a" / "b" !"a")+')
.parse('aba');
console.log(pegResult);
|
Sorry, I am a bit clumsy, as I've just started to learn the PEG. BTW, I've tried about dozen other parser generators (I am a newbie in this area) and this seems to be my favorite now) |
Yeah, peg's almost the only parser generator for Don't worry about being clumsy. We all are |
@vsemozhetbyt, actually, you grammar should issue a info/warning at build stage, because it accept only inputs, which are accepted by grammar
but compiler not (yet?) smart enough to infer that. I even don't know, may be it is NP-complete problem... |
the thing about np complete problems is that you can often still do a pretty decent job heuristically if it's often right and never wrong, then it's a defacto improvement |
Issue type
Prerequisites
Description
Error message for failed positive lookahead expression does not mention this expression
Steps to Reproduce
Consider a rule where double hyphens are not allowed:
Expected behavior:
Something like:
peg$SyntaxError: Expected "-" !"-", [^\-], or end of input but "--" found.
Actual behavior:
peg$SyntaxError: Expected "-", [^\-], or end of input but "-" found.
Software
0.11.0-master.b7b87ea
14.0.0-v8-canary202002123546737a75
npm 6.13.7
The text was updated successfully, but these errors were encountered: