Open jeffzoch opened 3 years ago
The tokens you declare with delegation are matched in the same order as declared. So if the tokenizing is ambiguous (which is often the case) then the tokens declared earlier are prioritized.
Note also this section in the README:
Note: the tokens order matters in some cases, because the tokenizer tries to match them in exactly this order. For instance, if
literalToken("a")
is listed beforeliteralToken("aa")
, the latter will never be matched. Be careful with keyword tokens! If you match them with regexes, a word boundary\b
in the end may help against ambiguity.
Im finding that the order I declare my delegates in a parser grammar affects whether or not it parses. I have a grammar like the following:
thats meant to parse
into a list of Commands. By just switching the order of str, queryType, and word the parse will fail / pass on different test cases with errors like
Could not parse input: UnparsedRemainder(startsWith=word@2 for "findFoo" at 39 (2:1))