[antlr-interest] Function Call,
Craig Main
craig at palantir.co.za
Thu Jun 30 04:41:23 PDT 2005
Finally, I have it.
>> If I try and generate with -traceTreeParser, I get unresolved symbols
>> everywhere because currentAST does not exist.
>>> That has to be a bug. Which antlr version are you using?
I am using 2.7.5, maybe it is a bug. I am generating C#
> If the -traceTreeparser does not work at least add a print to the top
> of each treeparser rule in the init section:
> rule { System.out.println("rulename"); }: .... ;
I have done this, and I get the following:
[SimpleAppConfig]: Executing Rule: statement
[SimpleAppConfig]: Executing Rule: expression
[SimpleAppConfig]: Executing Rule: term
[SimpleAppConfig]: Executing Rule: literal
[SimpleAppConfig]: Executing Rule: term
[SimpleAppConfig]: Executing Rule: literal
<AST>: unexpected AST node: func
[SimpleAppConfig]: TEMP = 4
It is taking a wrong turn to literal instead of matching the function.
I changed the grammar and moved the method call from expression down to
term, and now it works.
#(METHOD_CALL #(ELIST (expression)*)) {log.Info("Method Call");}
from the expression to the term.
term
returns [object result]
{log.Info("Executing Rule: term"); result = null;}
: result=literal
| #(METHOD_CALL #(ELIST (expression)*)) {log.Info("Method Call");}
;
This now works. It seems that the match for the method call was too high in
the tree?
I am trying to figure out why now?
I am not convinced of my understanding of this, but it does feel right
because it matches at that level in the parser as well.
Regards
Craig
More information about the antlr-interest
mailing list