Custom Token Pattern's matched result not being consumed #1880
Replies: 2 comments
-
Hey @lightchaser411,
Good question. It seems like your custom token pattern is a bit too eager in what it accepts. It'd be great if you were to share your code that implements the pattern as the error is likely somewhere in there. What I assume happens here is that your custom pattern matches the first description token correctly. Afterwards the lexer continues and tries to run your pattern again, which erroneously returns the same token, instead of returning Note that you can likely replace your custom pattern definition with a regex like |
Beta Was this translation helpful? Give feedback.
-
A good way to debug such issues is to track the output of the Lexer (array of tokens) and completely ignore the parsing step. |
Beta Was this translation helpful? Give feedback.
-
Hey, I'm pretty new to this, so bear with me.
What I'm doing seems relatively straightforward, and it looks like it's working as it should, but the behavior is incorrect.
I have simple grammar syntax:
A tab delimited description block initiated by a "`d" followed by at least one identifier as so:
In this case, we're not even running into tab delineation.
My rule in pseudo code is
My custom token pattern for description correctly returns:
The parser acknowledges this but then fails with an EarlyExitException on the at_least_one(identifier) trying to match against the same description string but on line two:
Offset 31 in the sample text is the 'o' in the observer, but the error message says the image is '`d'
Why is the description line on line 1 being replayed as line two against my identifier match
My identifier token is a simple
/[a-zA-Z]\w*/
Beta Was this translation helpful? Give feedback.
All reactions