[antlr-interest] learning tree grammar
Lloyd Dupont
ld at galador.net
Tue Jul 10 05:24:38 PDT 2007
Never mind, my own syntax error, nothing to worry about.
From: Lloyd Dupont
Subject: [antlr-interest] learning tree grammar
in the book there is an example with rewrite and label which is like that:
==
prog: main=method others+=method* -> ^(MAIN $main) $others* ;
==
I have tried a few variation in a test program like:
===
grammar TreeTest;
options {output=AST;}
tokens{ MAIN; }
r : first=atom others+=atom* -> ^(MAIN $first) $others*;
atom : ID | INT;
op : PLUS|MINUS;
ID : 'a'..'z' + ;
INT : '0'..'9' +;
PLUS : '+';
MINUS : '-';
WS : (' ' |'\n' |'\r' ) {$channel=HIDDEN;} ;
===
with input such as
===
23 jhkl 34 hjk 34
===
yet my resulting tree only the first 2 tokens: '23' and 'jhkl' (according to ANTRWorks debugger at least).
how could I include all the remaining token in the produced tree?!?!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070710/e98206b6/attachment.html
More information about the antlr-interest
mailing list