Checking Token is already consumed or not while parsing #2020
Answered
by
msujew
Siva-Harish98
asked this question in
Q&A
-
Is it possible to check wheather the token is consumed more than one time while parsing |
Beta Was this translation helpful? Give feedback.
Answered by
msujew
Mar 13, 2024
Replies: 1 comment 5 replies
-
Can you elaborate a bit? Chevrotain will consume a token at most one time. In case of parser errors, a token might be skipped, but the parser will never attempt to parse a token a second time. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I see, that's what you mean. I've seen in the other issue that you're using an
OR
inside theMANY
. You can use aGATE
property for theALT
that consumeson
to prevent it from being parsed again. Just flip a boolean after consuming the token once.Note that I would recommend to perform a validati…