Chevrotain / chevrotain

Parser Building Toolkit for JavaScript
https://chevrotain.io
Apache License 2.0
2.44k stars 199 forks source link

Consuming a TokenType received as rule parameter #1991

Closed jafeth-calderon closed 9 months ago

jafeth-calderon commented 9 months ago

Is there any way to do this? I send a TokenType as a parameter to a subrule but then it is taken as instead. I want to be able to consume a token conditionally according to the parameter received but I don't know if that's possible.

msujew commented 9 months ago

Due to the way the grammar recording phase works, arbitrarily changing the shape of the grammar during parser runtime isn't possible. I.e. every grammar rule is immutable and should not change during the runtime of the program.

jafeth-calderon commented 9 months ago

Got it! Thank you for the quick response.