[antlr-interest] Binary Expression Problem!

Muhammad Masoom Alam doublemalam at yahoo.co.uk
Mon Jun 19 23:23:21 PDT 2006


Hi All,

The Grammar below is structured in a way that it
should observes the perority of relational operators.
But in this Grammar one problem persists i.e. a Binary
Expression should be comprised of two operands where
as from the Grammar it is obvivous that it may come up
with a single operand too. Could any body help me in
this regard to overcome the single operand issue
without loosing the operator's perority.
e.g. the Grammar permits: "Hello" where as the
required expression is "Hello" = "Hello" without
loosing the operator's perority.

BinaryExp: EqualityExp;

EqualityExp: RelationalExp ((Not_Equal|Equal)
RelationalExp)*;

RelationalExp: additiveExp ((GT|GTE|LT|LTE)
additiveExp)*;

additiveExp: MultipicativeExp
((PLUS|MINUS)MultipicativeExp)*;

MultipicativeExp: SimpleExp ((MUL|DIV|MOD)
SimpleExp)*;

SimpleExp: STRING|CONSTANTVALUE;

Thanks
MA




	
	
		
___________________________________________________________ 
All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine 
http://uk.docs.yahoo.com/nowyoucan.html


More information about the antlr-interest mailing list