Closed spoenemann closed 3 years ago
Is there a case one would need to have rules defined above the root
rule?
No, it's just that I don't like the fact that the order of rules matters. It does not matter for the whole rest of the file, so it should not matter for the first rule as well.
Alternative keyword: entry
As I could imagine to have more than one entry rule I like entry
keyword much more, otherwise having more than one main entry rule will lead to the same ordering problem as without any keywords.
Maybe I'm mixing it with a parser "entry rule", we are talking hier about the root
AST rule/type, than entry
is not that good...
Maybe I'm mixing it with a parser "entry rule", we are talking hier about the root AST rule/type
Isn't that the same? Whatever entry rule is used by the parser will become the root node.
With Chevrotain you can use any rule as an entry rule, but for the langium document we should have only one. That why entry
keyword for a parser rule confuse me a bit.
root
keyword will reflect that the parser rule AST Type will became the root type.
main
keyword says that a parser rule will be used as a main or starting entry rule for the Langium document.
I don't like the fact that Xtext assumes the first rule to be the entry rule. I would prefer to make this explicit in Langium, e.g. with a keyword
main
orroot
. We could offer a code action that adds this keyword to the first rule to simplify migration from Xtext.