Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Considering below grammar, the generated parser code tolerates illegal expression like "NotExpression1 ANND NotExpression2", the parser just ignores the part "ANND NotExpression2". The solution is to explicitly declare EOF at the end of constraint definition. i.e. constraint: orexpression EOF;

Code Block
\---------------\- Grammar  \------------------\-

//  Constraint Rules

constraint:
      orexpression

     ;

orexpression

     :   andexpression ("or"\^ andexpression)\*

   

;

andexpression

    :  notexpression ("and"\^ notexpression)\*

     ;

notexpression

    :  ("not"^)? equalityExpression

     ;

equalityExpression

     :   relationalExpression ((NOTEQ\^NOTEQ^ \| EQUAL^)  relationalExpression)\*

     ;
\---------------\- End of Grammar 
\------------------\-