[antlr-interest] Re: yet more thoughts on error handling / recovery

micheal_jor open.zone at virgin.net
Tue Jun 29 14:45:19 PDT 2004


--- In antlr-interest at yahoogroups.com, Terence Parr <parrt at c...> wrote:
> 
> On Jun 28, 2004, at 9:19 PM, Monty Zukowski wrote:
> 
> >>
> >> Rather than print the grammar out as a string for use by the error
> >> reporting, perhaps the entire tree structure (i.e., the processed
> >> grammar) should be made available to the running parser. The grammar
> >> position would map to an actual AST node. The cost would be a
slightly
> >> larger string (flattened AST as string) compared to the original
> >> grammar, but would potentially provide more grammar information to a
> >> reporting facility. Hmm...actually, since the trees have down/right
> >> pointers (not up/left) it would be hard to walk backwards to
print out
> >> a larger portion of the grammar. Ok, forget that.
> >
> > It's not _that_ big a deal to implement up/left pointers.  See my GCC
> > grammar :)  Just jump up to the enclosing alt and you're set.
> 
> Doing in a general way for arbitrary tree construction when you have 
> actions involved can be tricky ;)

Not sure I agree. In one of my projects I found that most of the
issues {with tree-construction/tree-parsing} can be resolved with a
custom ASTFactory that understands that the custom ASTNode class had
parent/previousSibling links too.

I seem to remember needing a addChildEx() method. Can't quite remember
if this was due to a shortcoming in the ASTFactory model or was just
to keep some legacy code - that used addChild() - tickling along fine.

Cheers,

Micheal



 
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