-
Notifications
You must be signed in to change notification settings - Fork 204
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
Recovery at end of input not working? #1116
Comments
Hi @tlrobinson The simple examples certainly helps. 👍 I don't think the recovery logic handles the edge case of EOI. canRecoverWithSingleTokenInsertion(
this: MixedInParser,
expectedTokType: TokenType,
follows: TokenType[]
): boolean {
if (!this.canTokenTypeBeInsertedInRecovery(expectedTokType)) {
return false
}
// must know the possible following tokens to perform single token insertion
if (isEmpty(follows)) {
return false
}
let mismatchedTok = this.LA(1)
let isMisMatchedTokInFollows =
find(follows, (possibleFollowsTokType: TokenType) => {
return this.tokenMatcher(mismatchedTok, possibleFollowsTokType)
}) !== undefined
return isMisMatchedTokInFollows
} So to perform single token Insertion the encountered token must match a possible NEXT
However I do not believe EOF is counted as part of the possible next tokens. I've tried to explicitly add a CONSUME(chevrotain.EOF) at the end of the rule but without luck. |
All-right, I've debugged this again but this time using a full dev env instead of the playground. Adding an EOF token explicitly seems to resolve the problem.
It is possible to make a patch infer the existence of EOF as a "possible next token" in such a case, however because EOF is implicit it is a tiny bit complicated and may not be warranted or high priority when a simple workaround is available... |
I'm trying to get recovery to insert a token at the end of the input but it doesn't appear to be working. Here's a really simple grammar to parse function calls like
foo()
. I want it to also parsefoo(
using token insertion. Am I doing something wrong?The text was updated successfully, but these errors were encountered: