[antlr-interest] Tree parser to compress some tokens

Ilia Kantor ilia at obnovlenie.ru
Sat Dec 23 08:55:31 PST 2006


Hello,

I wrote parser for a grammar with rules:

id : namechar+;

alpha_num
	:	DIGIT | LETTER_ENG;

namechar
    : alpha_num | '_'
    ;

rule_output
	:	s_output id body -> ^(s_output id body);

BLOCK : '{' (BLOCK | ~('{'|'}'))* '}' ;
body: BLOCK;

But resulting AST for "output test {..}" has

"output" "t" "e" "s" "t" "{...}"

How to write a tree parser that will compress such "t" "e" "s" "t" sequences 
(parts of single id) into one token with "test" string ?
 


More information about the antlr-interest mailing list