[antlr-interest] rule rewrite

Fırat KÜÇÜK firatkucuk at gmail.com
Mon Apr 2 01:15:09 PDT 2007


this is simple sample inline calculator grammar:

start : operation ((PLUS^ | MINUS^) operation)* ;
operation : NUMBER ((ASTERISK^ | SLASH^) NUMBER)* ;

but i need:

start : operation ((ADDITION^ | SUBTRACTION^) operation)*;

how can i rewrite this rules without changing rule.

i tried to seperate to 2 rules:

start : additionOperation | subtractionOperation
additionOperation : operation (PLUS operation)* -> ^(ADDITION operation+)
subtractionOperation : operation (MINUS operation)* -> ^(SUBTRACTION
operation+)

any solution?




-- 
Öğr. Gör. Fırat KÜÇÜK
ADAMYO Distance Learning
SAKARYA University / TURKEY
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070402/aad2cd7e/attachment.html 


More information about the antlr-interest mailing list