[antlr-interest] Processing lists in a tree grammar

Arthur Goldberg goldberg at cbio.mskcc.org
Fri Nov 26 16:56:12 PST 2010


Hello All

It's me again!
As I wrote 
<http://www.antlr.org/pipermail/antlr-interest/2010-November/040124.html>, 
I'm writing a two-pass grammar. The AST generating code puts some 
repeating elements in a list:
> grammar completeOncoPrintSpecAST;
>
> options {output=AST;}
...
> fullDataTypeSpec
>     :    ':' ( dataTypeSpec )+ ';' -> dataTypeSpec+
>     ;
>
...

as per an example on p. 166 of Parr's "... ANTLR Reference" (TDAR):
> /** Collect the result trees from all formalArg invocations
> * and put into an AST list.
> */
> formalArgs :    formalArg (',' formalArg)* -> formalArg+
>  | ;
How does one walk these repeated elements in a tree grammar? I'm unable 
to find any documentation in TDAR or on antlr.org.

Thanks
A



More information about the antlr-interest mailing list