eclipse-langium / langium

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

Fix CST related parser issues #1547

Closed msujew closed 2 weeks ago

msujew commented 2 weeks ago

Closes https://github.com/eclipse-langium/langium/issues/1218 Closes https://github.com/eclipse-langium/langium/issues/1361 Supersedes https://github.com/eclipse-langium/langium/pull/932

Related discussion https://github.com/eclipse-langium/langium/discussions/1539

Mainly fixes 3 issues related to how we process CST/AST nodes during parsing:

  1. When performing an unassigned action (i.e. an action that just rewrites the type) we only adjust the type without touching anything else (see also https://github.com/eclipse-langium/langium/discussions/1539).
  2. When performing an assigned action, we need to rewrite the CST order (see https://github.com/eclipse-langium/langium/issues/1218 and https://github.com/eclipse-langium/langium/issues/1361).
  3. When performing an unassigned subrule call, we need to unassign the new node as the owner of the CST. Only after completing the CST construction does the current AST node become the owner of an CST node. Otherwise, we keep stale AST references in the CST (see #932).