Note that there are some explanatory texts on larger screens.

plurals
  1. POANTLR Grammar for expressions
    primarykey
    data
    text
    <p>I'm trying to implement a expression handling grammar (that deals with nested parenthesis and stuff). I have the following so far, but they can't deal with some cases (successful/failure cases appear after the following code block). Anyone know what's going on?</p> <p>Note: The <em>varname +=</em> and <em>varname =</em> stuff are just some additional AST generation helper stuff in XText. Don't worry about them for now.</p> <pre><code>... NilExpression returns Expression: 'nil'; FalseExpression returns Expression: 'false'; TrueExpression returns Expression: 'true'; NumberExpression returns Expression: value=Number; StringExpression returns Expression: value=STRING; //EllipsesExpression: '...'; //FunctionExpression: function=function; //don't allow random functions UnaryExpression: op=unop ('(' expr=Expression ')')|expr=Expression; BinaryExpression: 'or'? AndOp; //or op AndOp: 'and'? ComparisonOp; ComparisonOp: ('&gt;'|'&lt;'|'&gt;='|'&lt;='|'=='|'~=')? ConcatOp; ConcatOp: '..'? AddSubOp; AddSubOp: ('+' '-')? MultDivOp; MultDivOp: ('*' '/')? ExpOp; ExpOp: '^'? (('(' expr=Expression ')')|expr=Expression); ExprSideOne : Variable|NilExpression|FalseExpression|TrueExpression| NumberExpression|StringExpression|UnaryExpression; Expression: ( '(' expression1=ExprSideOne expression2+=BinaryExpression* ')' ) | ( expression1=ExprSideOne expression2+=BinaryExpression* ) ; ... </code></pre> <p>And here's the list of parses/fails:</p> <pre><code>c = ((b)); //fails c = ((a not b)); //fails c = b; //parses d = (b); //parses </code></pre>
    singulars
    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.
 

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