[antlr-interest] Rule return type limitations?

Rick Mann rmann at latencyzero.com
Sun Oct 14 17:37:36 PDT 2007


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