mihaibudiu commented on PR #3477:
URL: https://github.com/apache/calcite/pull/3477#issuecomment-1771366355
Sometimes you can modify the grammar to accept reserved keywords where
identifiers are allowed if the result is not ambiguous. If I understand right,
this is about AddArg in the parser:
```
LOOKAHEAD(2) name = SimpleIdentifier() <NAMED_ARGUMENT_ASSIGNMENT>
```
One could add `<OFFSET> <NAMED_ARGUMENT_ASSIGNMENT>` as a production and use
"OFFSET" for the identifier.
This can be generalized to define a new non-terminal IdentifierOrKeyword
which parses either identifiers or keywords and returns them as identifiers.
(We have used this trick in our P4 compiler
https://github.com/p4lang/p4c/blob/112b734b5b23500c53c199b30bb2d914c52c146c/frontends/parsers/p4/p4parser.ypp#L468
to extend the language adding additional keywords without breaking backwards
compatibility. The observation is that these keywords are often only legal
within narrow contexts, so it's not ambiguous if you find them elsewhere.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]