Replies: 1 comment 8 replies
-
These Java-style annotations always remind me of things that should have been part of the core language syntax (like I didn't get why you want to annotate parser rules: the lexing phase works only with the terminal rules (and keywords). It would be cool to see how a custom TokenBuilder using annotations of terminal rules could look like. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
I am about to write a grammar that uses multimode lexing. We have no equivalent to pushMode/popMode like it is done in ANTLR and it also might be better to keep that actions out of the Langium grammar specification (lower complexity of Langium).
But I had a second idea that might help to write other parts like TokenBuilder, ScopeProvider and other dependents of the grammar: Annotations on rules and other concepts.
Annotations could look like this:
Inside of the TokenBuilder you would be able to filter the rules by mode!
One downside I see is Langium's additional complexity of handling values. You certainly need a concept for constants to not duplicate StringLiterals all over the place. And we might also need some first StandardLibrary for the @annotation annotation...
The big advantage is that you could annotate any constant values, and you would not have to extend Langium grammar further, because it is possible to cover additional features with a mix of annotations and smart extensions (default implementation overrides).
Another thing is the syntax of the feature. We have to think well about what we want. Entire JSONs, primitive types, forbid lambda for complexity reasons. Bli Bla Blub
WDYT?
Beta Was this translation helpful? Give feedback.
All reactions