[antlr-interest] antlr vs. javacc+jjtree tree construction

mzukowski at bco.com mzukowski at bco.com
Wed Mar 27 06:12:43 PST 2002


If a rule has no tokens, then what would be in the tree?  What kind of rule
has no tokens?  What does it match?

It sounds like the jjtree approach introduces a new imaginary node type for
every rule.  Much of the time an existing token is more appropriate.  This
keeps the tree a bit more compact as well, making it quicker to tree parse.

Monty

> -----Original Message-----
> From: Robert Enyedi [mailto:renyedi at yahoo.com]
> Sent: Wednesday, March 27, 2002 5:23 AM
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] antlr vs. javacc+jjtree tree 
> construction
> 
> 
> Yes, but as far as I know you can apply the '^' operator to a 
> token. So what
> if the rule has no tokens?
> 
> ----- Original Message -----
> From: "Bogdan Mitu" <bogdan_mt at yahoo.com>
> To: <antlr-interest at yahoogroups.com>
> Sent: Wednesday, March 27, 2002 1:47 PM
> Subject: Re: [antlr-interest] antlr vs. javacc+jjtree tree 
> construction
> 
> 
> > Hi Robert,
> >
> > In ANTLR you normally use the '^' operator to direct the 
> AST construction.
> > Sometimes you need to add manually some nodes, but most of 
> the time '^'
> and
> > '!' do the job.
> >
> > Regards,
> > Bogdan
> >
> > --- Robert Enyedi <renyedi at yahoo.com> wrote:
> > > Hi, everyone
> > >
> > > I have worked previously with JavaCC and I used JJTree to 
> build syntax
> > > trees. By default, it creates a root node for each grammar rule
> > > (identified by the constant JJT<RULENAME>) and attaches 
> to it as child
> > > nodes the nodes that come from its sub rules.
> > >
> > > When I got to use buildAST in ANTLR for the first time, I 
> noticed a
> > > fundamental difference: by default it creates a list of 
> token nodes. It
> is
> > > true that if I want the same behavior as in JavaCC, I can 
> use the action
> > > {#ruleName=#([NODE_TYPE_NAME],#ruleName);} and define 
> NODE_TYPE_NAME in
> > > the tokens section.
> > >
> > > But why do I have to do this manually? Isn't there a workaround to
> > > automate this task? And, somehow, isn't JJTree's behavior 
> the natural
> one?
> > >
> > > I would really like to discuss this issue with you, guys.
> > >
> > > Robert
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Movies - coverage of the 74th Academy Awards®
> > http://movies.yahoo.com/
> >
> >
> >
> > Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list