[antlr-interest] Tree parser to compress some tokens
    Terence Parr 
    parrt at cs.usfca.edu
       
    Sat Dec 23 09:02:56 PST 2006
    
    
  
Hi.  Don't match characters in the parser.  use ID and NAMECHAR and  
ALPHA_NUM.  then s : ID ;
Ter
On Dec 23, 2006, at 8:55 AM, Ilia Kantor wrote:
>
> 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