[antlr-interest] How to write template for rules with optional node?
    Yang Jiang 
    yang.jiang.z at gmail.com
       
    Sat Jun 16 21:07:26 PDT 2007
    
    
  
Hi list,
I'm trying to write a template for such a rule,
function_call :
		ID '.' '(' argument_list? ')' 
	       ->
	      <<
	       template(function_name={$ID.text},
function_args={$argument_list.st})
                  >>
	      ;
this works fine for input such as "aSimpleMethod(arg1, arg2)", 
but since the argument_list is optional, for input like "aSimpleMethod()",
the argument_list is null, and will cause a NullPointerException as antrl
will try to access the "st" attribute of "argument_list".
So, how can I handle this problem?
Thanks,
Yang
    
    
More information about the antlr-interest
mailing list