-
I am writing a Langium grammar for a DSL where some variables ("properties") need to be prefixed with an My desiderata are:
Right now I have
This satisfies 2. but not 1 (we can put whitespace after the
Then I can achieve 1. but not 2. because Langium looks for Is there an easy way to make it work? Ideally I would like to have a terminal rule that only returns part of the whole match (e.g., a group). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @lou1306, you're already doing well by using For the second part, this becomes a bit less trivial. Langium exposes an AST element always by its canonical name. By default, this is the name that you assign using the |
Beta Was this translation helpful? Give feedback.
Hey @lou1306,
you're already doing well by using
PROPREF
as part of the reference. I.e. by usingvariable=[Prop:PROPREF]
.For the second part, this becomes a bit less trivial. Langium exposes an AST element always by its canonical name. By default, this is the name that you assign using the
name
AST property. I.e. if you name an elementvar
, it will only be addressable by the namevar
. If you want to give it a different (or even multiple) canonical names, you will need to modify theScopeComputation
service. We have a guide on how to do that here. The guide uses fully qualified name scoping, but that is also just another way of exposing an element using a different name (a fully qualified…