Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make entry rule explicit #68

Closed
spoenemann opened this issue Jun 15, 2021 · 6 comments · Fixed by #305
Closed

Make entry rule explicit #68

spoenemann opened this issue Jun 15, 2021 · 6 comments · Fixed by #305
Assignees
Labels
grammar Grammar language related issue
Milestone

Comments

@spoenemann
Copy link
Contributor

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.

@spoenemann spoenemann added the grammar Grammar language related issue label Jun 15, 2021
@dhuebner
Copy link
Contributor

dhuebner commented Jun 15, 2021

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

@spoenemann
Copy link
Contributor Author

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 spoenemann added this to the v0.3.0 milestone Sep 24, 2021
@spoenemann
Copy link
Contributor Author

Alternative keyword: entry

@dhuebner
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
grammar Grammar language related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants