Closed jerome-trc closed 5 days ago
For context, I was attempting to define a grammar for a language which does not declare any keywords to its lexer in the formal sense. Instead, its lexer only tokenises identifiers, and the parser then checks the strings of these identifiers to determine if they match the keywords to assemble syntax elements.
I was trying to replicate this behaviour in Lady Deirdre by making each syntax node use #[rule($Identifier)]
as its left-most set, and then defining custom parsers for each which manually check for chains of identifiers matching the keywords.
Bug confirmed. Thank you for reporting!
A note regarding your approach. I think matching on the generic tokens in the parser's context is fine, but you don't need a parsing rule for each of these Keyword-nodes. Here is an example: https://gist.github.com/Eliah-Lakhin/4c543cdf7415c1c2b98c88e353beb87f
In the snippet from the description, normally the macro should yield a grammar error message because A and B have overlapping leftmost sets. But for some obscure reason, it throws an assertion error that I'm currently investigating.
Ok, I think I found the root cause and fixed it. Now the macro yields the correct error message:
error: Rule "B" with "$LitTrue" token in the leftmost position conflicts with rule "A" that contains the same token match in its leftmost position.
--> crates/playground/src/lib.rs:23:26
|
23 | #[rule((top: A | B)*)]
| ^
The fix is in the issue-19-proc-macro-node-panic-duplicate-covered-token
branch.
I can confirm this occurs on v2.0.1, bdb70e22 and fb029833. Minimal reproduction: