You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I run into the issue that Grammar-Kit reports the unexpected token as also being expected. After some debugging, I was able to create a small example that demonstrates the issue.
file ::= root
root ::=
parens AFTER
| parens
parens ::= '(' content ')' { pin=1 }
content ::= A B { pin=1 recoverWhile=parens_recover }
private parens_recover ::= !')'
It looks like the following requirements must be met to make Grammar-Kit report expected tokens incorrectly.
You need a choice expression with two (or more) choices. (i.e. root)
The first (or at least not last) choice must have two nested pinned expressions. (i.e. parens and content)
The second pinned expressions must fail after it has been pinned but before the last token has been consumed. (i.e. content)
The second choice must fail at the same token as the previous choice.
The problem is that parens adds ) to ErrorState.variants while evaluating the first choice. Since the error message has already been generated for the current frame, the error message is not yet affected. When evaluating the second choice, the parser runs into the exact same error but with ) still being saved as a variant. Since we are outside the frame of the first choice, the parser will override the error reported previously but acknowledge the incorrect variant ).
The text was updated successfully, but these errors were encountered:
JojOatXGME
changed the title
Unexpected token reportet as expected token
Unexpected token reported as expected token
Feb 14, 2021
I run into the issue that Grammar-Kit reports the unexpected token as also being expected. After some debugging, I was able to create a small example that demonstrates the issue.
I created a GitHub repository for reproduction. The error message for the input
(A)
isIt looks like the following requirements must be met to make Grammar-Kit report expected tokens incorrectly.
root
)parens
andcontent
)content
)The problem is that
parens
adds)
toErrorState.variants
while evaluating the first choice. Since the error message has already been generated for the current frame, the error message is not yet affected. When evaluating the second choice, the parser runs into the exact same error but with)
still being saved as a variant. Since we are outside the frame of the first choice, the parser will override the error reported previously but acknowledge the incorrect variant)
.The text was updated successfully, but these errors were encountered: