[antlr-interest] Building XML like AST

Michele Bortolato zuper85 at hotmail.it
Wed Jan 16 13:04:05 PST 2008


Hi.

let's suppose i have a grammar like this:

prog:   expr+ ;

expr:   multExpr (('+'|'-') multExpr)*
    ; 

multExpr
    :   atom ('*' atom)*
    ; 

atom:   INT
    |   '(' expr ')'
    ;

// START:tokens
INT :   '0'..'9'+ ;
NEWLINE:'\r'? '\n' ;
WS  :   (' '|'\t'|'\n'|'\r')+ {skip();} ;

i need to generate an AST for this grammra in XML form.

example, for a string like 3*4+5

i could need an output such:


   
      3
      4
   


instead of :(* 3 (+ 4 5))

could ANTLR(WORKS) generate an XML element rather than a CommonType tree?How?

I didn't found anything on  ANTLR Reference.

Thanks
_________________________________________________________________
Ti piace giocare con le lettere? Prova ABCLive!
http://messengergiochi.it.msn.com/


More information about the antlr-interest mailing list