[antlr-interest] Rule return type limitations?
Terence Parr
parrt at cs.usfca.edu
Sun Oct 14 17:54:16 PDT 2007
Hi Rick. You need to say $bytes.outBytes to access return value.
ter
On Oct 14, 2007, at 5:37 PM, Rick Mann wrote:
> I would like to return an arbitrary object type from one of my
> rules (an object I've defined outside of the grammar):
>
> ...
> sendCommand
> : 'send' bytes Semicolon {System.out.println("Sending " +
> $bytes.toString);}
> ;
>
> bytes returns [ByteBuf outBytes]
> : e=StringLiteral {//some stuff here to create a ByteBuf from e
> and return it};
>
> ...
>
> But when I try to generate the parser from this, I get
>
> ANTLR Parser Generator Version 3.0.1 (August 13, 2007) 1989-2007
> error(116): ../CommScript.g3pl:34:27: unknown attribute for rule
> bytes: toString
>
>
> Can I do this? What are the limitations on the return types?
>
> TIA,
>
> --
> Rick
More information about the antlr-interest
mailing list