eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
754 stars 68 forks source link

Make entry rule explicit #68

Closed spoenemann closed 3 years ago

spoenemann commented 3 years ago

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 or root. We could offer a code action that adds this keyword to the first rule to simplify migration from Xtext.

dhuebner commented 3 years ago

Is there a case one would need to have rules defined above the root rule?

spoenemann commented 3 years ago

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.

spoenemann commented 3 years ago

Alternative keyword: entry

dhuebner commented 3 years ago

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...

spoenemann commented 3 years ago

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.

dhuebner commented 3 years ago

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.