Contextual tokens #10
Replies: 5 comments 3 replies
-
A minimal improvement might be achieved using Token value comparators |
Beta Was this translation helpful? Give feedback.
-
I'm not sure it's the significant revisiting ANTLR architecture, I suspect token value can be treated just as token on the parser side. I'll try to experiment with it the original repository (separated branch) at first. |
Beta Was this translation helpful? Give feedback.
-
I think there are a lot of languages which (unfortunately) use soft keywords, and it can be tricky to support them, so I think this would be very useful |
Beta Was this translation helpful? Give feedback.
-
FYI, I'm working on prototype (the best activity for Christmas vacation). I hope I'll publish first steps at the beginning of the January, it looks promising. |
Beta Was this translation helpful? Give feedback.
-
I'm not convinced that the soft token feature addresses all contextual token scenarios, but it certainly addresses most of them in a very simple way. So I'd suggest closing this topic for now. |
Beta Was this translation helpful? Give feedback.
-
Some lexer patterns change meaning depending on the context.
As an example, in C#
value
is a keyword in a property setter, and un mundane identifier elsewhere.In typescript,
const
is a keyword, but is also a valid property identifier:At present, grammar developers need to go though painful gymnastics in order to support lexer patterns that have a different meaning depending on the context.
Disclaimer: implementing this requires revisiting significantly the current antlr architecture.
Beta Was this translation helpful? Give feedback.
All reactions