eclipse-langium / langium

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

Check the state of optional unordered group handling #803

Open dhuebner opened 1 year ago

dhuebner commented 1 year ago

As described here optional elements inside an unordered group are currently not supported.

We should check how the new Chevrotain implementation affects the current unordered group implementation. Depending on the result remove existing validation, or implement a solution so that unordered groups are handled correctly.

dhuebner commented 1 year ago

Update: Using an optional unordered group element currently leads to a stack overflow. Same problem exists also when an optional alternative is used inside a many group:

( prop1='prop1'? | prop2='prop2')*
spoenemann commented 1 year ago

Is it the same stack overflow as in #775?

dhuebner commented 1 year ago

@spoenemann No. Here it is inside the chevrotain-allstart package. Could we address this issue before v1.0.0?

l-ehlers commented 1 year ago

While experimenting with unordered groups, I found out that Chevrotain (or Langium?) treats all options within an unordered group as optional anyway, i.e., ('a' & b') matches `,a,b,a b,b a. Therefore, it acts exactly how I would expect('a'? & 'b'?)to work, which means both expressions are equivalent. Of course, the same applies to('a'? | 'b'?)vs.('a' | 'b'), just that these also allow duplicates ofaandb`.

Maybe you have already known that. If no modification in Chevrotain is made, doesn't that mean that there are the following two options?

  1. Disallow both ('a'? | 'b'?)* and ('a'? & 'b'?) with a validation message that recommends using an expression without ?
  2. Remove the optional modifier internally before passing the grammar rules to Chevrotain