[antlr-interest] Simplify tree construction rule

Martijn Reuvers martijn.reuvers at gmail.com
Wed Aug 26 08:37:06 PDT 2009


Hello,

Does not really look that complex to me, but you could probably
concatenate it in the lexer (but for that you need a real token) or
use something like:


tokens {
	SPACE = ' ';
}

aaa
    :		'TYPE' ' '? 'AAA' -> 'TYPE' SPACE 'AAA'
    ;

However this will result in 3 nodes, but concatenated again they are
the text you want... but the grammar is still more lengthy.

Martijn

On Tue, Aug 25, 2009 at 10:53 PM, Thomas Trummer<th.trummer at gmail.com> wrote:
> Hi,
>
> is it possible to simplify this rule?
>
> aaa
>     :   ('TYPE AAA'   | 'TYPE' 'AAA'  ) ';' -> 'TYPE AAA'
>     ;
>
> It basically allows space between TYPE and AAA, but the tree node should
> always be "TYPE AAA".
>
>
> Thomas
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>


More information about the antlr-interest mailing list