eclipse-langium / langium

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

Implemented option for parsing text with an alternative entry rule #1407

Closed spoenemann closed 2 months ago

spoenemann commented 4 months ago

See discussion #1404. This PR adds an option to LangiumParser so one can change the entry rule used for parsing a given text.

cdietrich commented 4 months ago

nice

Lotes commented 3 months ago

Really nice! One concern I have found is scoping. When there is a cross-reference that needs to be resolved, the scope provider writer cannot assume anymore that there are "natural" parents given. Like getContainerOfType would just return undefined, where actually a node is always expected, due to the nature of a translation unit (Like every statement is in a unit. When we only parse a statement we cannot go up to the outer scope). I am wondering how we should reflect this in the documentation...

spoenemann commented 2 months ago

If you use this new feature, you should be aware of the potentially added complexity. Scoping may be completely broken. If you want to support resolving references with a partial model, you need to consider that explicitly in your custom scope provider. The generic one shouldn't have any issues.