[antlr-interest] Bugs generating a tree walker?

Manu manunews at gmail.com
Sun Jan 21 23:01:09 PST 2007


Hi

> The ']' terminates the [...] action.  Try \[, though I am not sure
> that that works.


escaping it doesn't help. Hopefully you can add array support for
types inside the [...] in a future.


> > 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.


Yes, but looking at the source code, I found this:

LIST_LABEL_INVALID_UNLESS_RETVAL_STRUCT(arg) ::=
"rule '+=' list labels are not allowed unless building trees: <arg>"

so, based on the name, I added another parameter... and it worked.

Thanks


More information about the antlr-interest mailing list