[antlr-interest] Can't create AST Node?

Tiller, Michael (M.M.) mtiller at ford.com
Mon Jul 19 07:00:23 PDT 2004


Terrence,

  The main difference I see is that I never really understood how to
"subclass" a tree parser in ANTLR.  It seems like you have to create a
new .g file *and* the production rules/patterns everytime you want to do
something.

  In SableCC it looks like you get, as generated code, the complete
framework with "slots" for all the potential places where you would want
to put code (in, case, out).  One subtle point is that it seems like it
might be possible in SableCC to reorder the processing of the child
nodes by changing the "case###" methods.  This was something I ran into
with ANTLR.  Specifically, I constructed my AST during parsing so that
it was either easy to construct or unambiguous to parse as a tree but
then during the tree walking stage, I didn't necessarily want to process
the child nodes in the order that they appeared in the AST.

  On the other hand, it isn't clear to me how SableCC handles walking
for trees that didn't come out of a parser (I haven't looked into it
that much though).  This seems to be something that ANTLR excels at
(i.e. being able to write a tree parser for each pass of the process).

  Does that help?

--
Mike

> -----Original Message-----
> From: Terence Parr [mailto:parrt at cs.usfca.edu]
> Sent: Friday, July 16, 2004 4:06 PM
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] Can't create AST Node?
> 
> 
> On Jul 16, 2004, at 12:49 PM, Tiller, Michael (M.M.) wrote:
> 
> >
> >> From: Monty Zukowski [mailto:monty at codetransform.com]
> >> Subject: Re: [antlr-interest] Can't create AST Node?
> >>
> >>> One last comment, I suspect that it might be useful to provide
> >>> automatic
> >>> "visitor generation" for people where visitors seem more
attractive
> >>> (ala
> >>> SableCC?).
> >>
> >> Seems like that would be easy enough to add.
> >
> > Specifically, you might want to take a look at Chapter 6 of this:
> >
> > http://sablecc.org/downloads/thesis.pdf
> >
> > I found it quite interesting and found myself craving such features
> > (although what do I know).
> 
> Hi Mike,
> 
> SableCC is nice.  A visitor is sometimes precisely what you want, but
> more often you want to apply grammatical structure (i.e., context)
> rather than just say 'when I'm in this node, print this value'.  From
> my skim I couldn't see how it was different.  Can you help me out?  Is
> it building a visitor that is sensitive to the structure you create in
> the parser?  Can I use this context when visiting or is it still a
> node-centric algorithm?
> 
> Thanks,
> Ter
> --
> CS Professor & Grad Director, University of San Francisco
> Creator, ANTLR Parser Generator, http://www.antlr.org
> Cofounder, http://www.jguru.com
> Cofounder, http://www.knowspam.net enjoy email again!
> Cofounder, http://www.peerscope.com pure link sharing
> 
> 
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 



 
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