[antlr-interest] Problem with template rewrite, List return value

Mark Gressett Mark.Gressett at sas.com
Wed Jun 13 12:07:42 PDT 2012

Hi all,

Using ANTLR V3.1, I'm trying to rewrite something like
aFunction(anObject, arg1, arg2, arg3)
anObject.aFunction(arg1, arg2, arg3)

My grammar recognizes a function call as
function_call : ID arg_list;

arg_list returns [List listValues]:
'(' vals+=expression? (',' vals+=expression)* ')'{$listValues = $vals;}

I have arg_list return a List so that I can manipulate the list values at the function_call level. expression has no return value.

When I execute the example above, listValues contains 4 nulls, the result of adding expression_return.getTemplate(). expression_return.getTemplate() returns member st, which is never assigned a value, so retains default value, null.

I know there must be a way to return template text for the expressions in the arg list without adding return values throughout the parser. What am I missing?


More information about the antlr-interest mailing list