[antlr-interest] Concatenation in Tree Rewriting

Louis Rose louis at cs.york.ac.uk
Tue Aug 12 05:57:47 PDT 2008


Hi all,

I was wondering if there's a more elegant way to write the intentions of 
the following grammar rule:

adjective
       :   ADJECTIVE_PREFIX? NAME -> {new CommonTree(new 
CommonToken(ADJECTIVE, ($ADJECTIVE_PREFIX.text == null ? $NAME.text : 
$prefix.text + $NAME.text)))}
       ;

The ADJECTIVE token type is an imaginary token, and has been defined in 
the tokens {} block.

Cheers,
Louis.


More information about the antlr-interest mailing list