[antlr-interest] Tree grammar: How to handle rule arguments

Bart Kiers bkiers at gmail.com
Fri Oct 15 23:26:41 PDT 2010


On Sat, Oct 16, 2010 at 1:16 AM, Stephanie Balzer <
stephanie.balzer at gmail.com> wrote:

>
> ... What is the meaning of id+= above?
>
>
A java.util.List is defined at the start of the rule and
all Identifier-tokens are added to it.

        Token id=null;
        List list_id=null; *// <- !!!*

        try {
            // Test.g:17:3: (id+= Identifier ( ',' id+= Identifier )* )
            // Test.g:17:6: id+= Identifier ( ',' id+= Identifier )*
            {
            id=(Token)match(input,Identifier,FOLLOW_Identifier_in_ids80);
            if (list_id==null) list_id=new ArrayList();  *// <- !!!*
            list_id.add(id);  *// <- !!!*
            ...

Regards,

Bart.


More information about the antlr-interest mailing list