[antlr-interest] "Treeparser returns" question
camiel at srxp.com
camiel at srxp.com
Tue Oct 17 12:19:36 PDT 2006
Hope plain text will work better...:
Hi you all,
I have a question on the proper syntax of Treeparser methods. Suppose
that you want to parse "a=1" or just "a"
with the following parser rule:
class myparser extends Parser
statement: IDENTIFIER (EQUALS INT)? EOF!;
and we want to echo the evaluation via an extension of the treeparser,
the following is not going to work:
class mytreeparser extends TreeParser
statement returns [String s]
{String a; int b; s=""}
: # (IDENTIFIER a=identifier) {s=a"}
| # (EQUALS a=identifier, b=integer) {s=a+b;};
where identifier and integer are defined in the lexer.
My question is: what would work? The answer possibly centers around
method overloading (with different sets of parameters) but how exactly
I cannot figure out from online sources. Maybe anybody has written some
elaborate tutorial piece on this functionality of Antlr !??
Thanks anyway,
Camiel
More information about the antlr-interest
mailing list