[antlr-interest] Heterogeneous AST: returns [ Tom/Jerry]
me 262
me262c at gmail.com
Thu Apr 5 18:45:53 PDT 2007
Hi,
In the calc example, we saw an int gets transformed into a float
(see below). But what if we want to do this:
expr returns [Tom tom] .....
expr returns [Jerry jerry] ....
Do we need write Tom and Jerry into strings and read back? Can we
return a void * and cast it in different ways?
Any more examples besides the good old calc?
//------------------------------------------------
expr returns [float r]
{
float a,b;
r=0;
}
: #(PLUS a=expr b=expr) {r = a+b;}
| #(STAR a=expr b=expr) {r = a*b;}
| i:INT {r = atof(i->getText().c_str());}
;
More information about the antlr-interest
mailing list