Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A working Xtext grammar for your problem is this:</p> <pre><code>Model: term += Term*; Term: c=Collection; Collection: ( =&gt; Map | Set ); Map: '{' {Map} ( entries += MapEntry ( ',' entries += MapEntry )* )? '}'; MapEntry: key=Term ':' value=Term; Set: '{' ( values += Term ( ',' values += Term )* )+ '}'; </code></pre> <p>Thing to notice:</p> <ul> <li><p>The <code>=&gt;</code> syntactic predicate in the <code>Collection</code> rule. This directs Xtext/ANTLR into the right direction. (<a href="http://www.eclipse.org/Xtext/documentation.html#antlr_errors" rel="nofollow">Docu here</a>)</p></li> <li><p>The <code>{Map}</code> "simple action" (<a href="http://www.eclipse.org/Xtext/documentation.html#_36" rel="nofollow">Docu here</a>) creates a <code>Map</code> even if the content is empty.</p></li> <li><p>The additional <code>MapEntry</code> rule is also required because otherwise you have nothing to hold key/value pairs.</p></li> <li><p>Your grammar allow both <code>{}{}{}</code> and <code>{}, {}, {}</code> within a <code>Set</code>. This may or may not be what you want.</p></li> </ul> <p>So it seems to me, that the Xtext/ANTLR error message about LL recursion is not the most appropriate in this case. It is not about LL recursion but about ambiguities in the grammar which sometimes can be solved by applying <code>=&gt;</code>. See the linked docs for more details.</p> <p>Just for reference: The grammar can parse simple and nested stuff like this:</p> <pre><code>// Maps {} { {} : {} } { {} : {}, {} : {}} // Sets { {} } { {} {} {} {} } { {}, {}, {}, {} } // nested / mixed { { { {}:{} } } : {}, {} : { {}:{} }} { { { {}:{} } } : {}, {} : { {}:{ {}{}{} } }} </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload