[antlr-interest] A little problem in actions
Anakreon
p98043 at rainbow.cs.unipi.gr
Thu Dec 25 04:43:06 PST 2003
Hello all.
I'd like to report a little problem which I am facing.
Consider this rule in a tree parser:
expression
:
...rules
|! #(EQ_COMP eq_comp1:expression { #eq_comp1 = getDefault(#eq_comp1);}
eq_comp2:expression { #eq_comp2 = getDefault(#eq_comp2);
//int code = EQ_COMP;
#expression = #([EQ_COMP, "="], #eq_comp1, #eq_comp2);
;
When the produced parser is compiled, this error apears.
========================================================
Found 1 semantic error compiling
"/home/e/code/java/aspParser/build/src/gr/omadak/leviathan/asp/VbsTree.java"
expression_AST = (AST)astFactory.make( (new
ASTArray(3)).add(astFactory.create(tmp33_AST,"=")).add(eq_comp1_AST).add(eq_comp2_AST));
Semantic Error: No applicable overload for the method named "create" was found
in type "antlr.ASTFactory". Perhaps you wanted the overloaded version
"antlr.collections.AST create(antlr.Token $1, java.lang.String $2);" instead?
=========================================================
T guess this happens because the EQ_COMP in the action is miss taken as the
token EQ_COMP in the matching rule.
The problem is easily solved if instead i rewrite the rule:
expression
:
...rules
|! #(EQ_COMP eq_comp1:expression { #eq_comp1 = getDefault(#eq_comp1);}
eq_comp2:expression { #eq_comp2 = getDefault(#eq_comp2);
int code = EQ_COMP;
#expression = #([code, "="], #eq_comp1, #eq_comp2);
;
However this is awkward.
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list