You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The generated ast.ts file will contain a new type:
export type Root = Model;
"Root" here is just an example, but I suppose this will be better to use a name that cannot be used as a type name in the grammar.
This is useful for reflection since, as far as I know, there is currently no way to know statically which interface is the root one.
The text was updated successfully, but these errors were encountered:
You could have one Langium project with multiple grammars contributing a different root node each.
What would you like to solve? Having explicit entry points? Why is this so important? As the author of your language you know the root.
Just some thoughts. You might have a good argument…
You could have one Langium project with multiple grammars contributing a different root node each.
Indeed, I didn't think about this point.
After consideration, a type for that is not a good idea.
However, having somewhere this information can be useful. Not necessary for the language designer but for reflection purposes and external libraries. To iterate over the abstract syntax definition at a higher level of abstraction.
We already have the AstReflection providing some useful information in this direction, adding information about the root type can be more relevant in this class, for instance if the getTypeMetaData function.
A really simple suggestion: add in the
ast.ts
a new type corresponding to the type being returned by the entry rule.For instance, with the Hello World example:
The generated
ast.ts
file will contain a new type:"Root" here is just an example, but I suppose this will be better to use a name that cannot be used as a type name in the grammar.
This is useful for reflection since, as far as I know, there is currently no way to know statically which interface is the root one.
The text was updated successfully, but these errors were encountered: