[antlr-interest] grammar for boolean expressions

poroshpathor poroshpathor poroshpathor81 at yahoo.com
Mon Apr 11 15:47:30 PDT 2011


Hello,

I am trying to build  grammar rules for the following boolean expression.
E1 AND E2 AND E3 AND ... AND En
Here, E1, E2,...,En could consist boolean expressions of both OR and AND
I have started with this 


expression
: or_relationalExpression ( AND^ or_relationalExpression)*
;

or_relationalExpression
: relationalExpression (OR^ | AND^ relationalExpression )* 
;

But, as expected, it causes problems of following format
Any idea to solve or rewrite the grammar rules??

Thanks in advance.


[fatal] rule or_relationalExpression has non-LL(*) decision due to recursive 
rule invocations reachable from alts 2,3.  Resolve by left-factoring or using 
syntactic predicates or using backtrack=true option.
 |---> : relationalExpression (OR^ | AND^ relationalExpression )*

warning(200): /CarFast/src/ConditionsGrammar.g:55:58: Decision can match input 
*** using multiple alternatives: 2, 3 As a result, alternative(s) 3 were 
disabled for that input
 |---> : relationalExpression (OR^ | AND^ relationalExpression )*



      


More information about the antlr-interest mailing list