[antlr-interest] Not generating parts of AST (argh!)
Monty Zukowski
monty at codetransform.com
Sun Oct 24 20:48:03 PDT 2004
On Oct 24, 2004, at 8:32 PM, Paul J. Lucas wrote:
>
> On Sun, 24 Oct 2004, Monty Zukowski wrote:
>
>> Try -traceParser when you run antlr.tool. What tree is mulExpr
>> returninng?
>
> Exactly what it should. After yet more time spent in the
> debugger, I discovered that I had a rule like this as its
> parent:
>
> comparisonExpr!
> {
> boolean gotR2 = false;
> }
> : re1:rangeExpr
> (co:comparisonOp re2:rangeExpr { gotR2 = true; })?
> {
> if ( gotR2 )
> #comparisonExpr = #(co, re1, re2)
> else
> #comparisonExpr = #(re1); // <-- bug
> }
> ;
>
> The "bug" line should read:
>
> #comparisonExpr = #re1; // no ()
>
> Damn parentheses! Anyway, is there a simpler way to do the
> above (without the boolean gotR2 flag)?
>
> - Paul
>
Maybe I'm missing something, but isn't that equivalent to
comparisonExpr:
rangeExpr (comparisonOp^ rangeExpr)?;
Monty
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