[antlr-interest] Interp Class

Fırat KÜÇÜK firatkucuk at gmail.com
Thu Mar 29 01:17:17 PDT 2007


Hi,

i send a sample post to antlr-dev list. But i didn't receive a response.

-------------------------------------------

There is an Interp class in org.antlr.tool package.
It generates an AST according to the parser grammer.
But ignores automatic tree generation statements.

my sample calculator grammar is:

start                   :    (operationSecond (EOL operationSecond)* EOL?)?;
operationSecond  :    operationFirst ((PLUS^ | MINUS^) operationFirst)* ;
operationFirst      :    NUMBER ((ASTERISK^ | SLASH^) NUMBER)*;

for instance : 1 + 56 + 3 * 2

Interp generates:

(<grammar HesapMakinesi> (start (operationSecond (operationFirst 1) +
(operationFirst 56) + (operationFirst 3 * 2))))

but i want:

(+ (+ 1 56) (* 3 2))

any solution?



-- 
Öğr. Gör. Fırat KÜÇÜK
ADAMYO Distance Learning
SAKARYA University / TURKEY


More information about the antlr-interest mailing list