[antlr-interest] AST imaganary node in tree parser

向秦贤 fyaoxy at gmail.com
Mon Aug 27 19:36:25 PDT 2007


Hi,
In my ON grammar, there is a rewrited imaginary node, and I want to
make a tree parser, but I found I try times but cannot get a right
result.
Could someone give me a handle:)

grammar Imaginary;
options{output=AST; ASTLabelType=CommonTree;}
tokens{ARRAY;STRING;STR;}
stringArray:string (',' string)* ','?->^(ARRAY string+);
string: words->^(STR[$text]);
words: WORD+;
WORD:(~(' '| '\t'))+;
WS    :    (' ' | '\t')+ {$channel=HIDDEN;};

there are 2 points in above grammar:
1,string:words; because I need quoted string, like
string:words|QSTRING; in this case ignored.
2,I cannot state my mean with tree parser grammar, because I not know
how to handle string rule in tree parser, and I need help :-)

Thanks

-- 
致敬
向秦贤


More information about the antlr-interest mailing list