[antlr-interest] Bugs generating a tree walker?
Terence Parr
parrt at cs.usfca.edu
Sun Jan 21 15:27:00 PST 2007
On Jan 21, 2007, at 3:07 PM, Manu wrote:
> Hi,
>
> The following problems were found using ANTLR 3.05b.
>
> I'm creating a tree walker and I have noticed two strange things:
>
> 1) If you create a rule with a return type like this:
>
> genericTypeArgs[int num_params] returns [Type[] types]
>
> the generated code has a return type of Type not Type[]. Is this a bug
> or arrays are not supported?
hi
The ']' terminates the [...] action. Try \[, though I am not sure
that that works.
>
> 2) With the following rule:
>
> genericTypeArgs[int num_params] returns [Type[] types]:
> ^(ARG_LIST (type_names+=typeName)*)
>
> ANTLR gives an error:
>
> error(134): TypeExpressionEval.g:49:69: rule '+=' list labels are not
> allowed unless building trees: type_names
>
> However, if I change the rule to return two values:
>
> genericTypeArgs[int num_params] returns [Type[] types, int
> aux]: ^(ARG_LIST (type_names+=typeName)*)
>
> it works without changing anything more. Any idea why???
that's weird.
Ter
More information about the antlr-interest
mailing list