[antlr-interest] nesting rules, getting rule text

Robin Debreuil robin at debreuil.com
Fri Mar 5 01:12:41 PST 2004


For sure - I think I've soaked up more Antlr docs in the last month than is
healthy, but pointers on more specific situations would be really helpful.
Not so much syntax things, but more the 'subjective' stuff. I'm fairly
comfortable getting antlr to do what I want, but I'm not sure if the way I
do it is the recommended way, or even if what I want is something I should
want... An example, what should streams look like after the lexer, after the
parser and tree walkers? Of course they can look like anything you want, but
strong advice helps -- things like  'do like this unless you know you need
something else', vs 'you prefer something else' vs 'you like slow parsers
and confusing grammars'. Knowing how the various trade offs will affect
things like effeciency, size, ease of reading, ease of next stage of parsing
etc really helps out. Even things like when should you record types, what
should be child vs what should be sibling, what is better off in the
lexer/parser/later stages...

Mostly it is that you build the lexer without having ever built an antlr
parser, so you don't really know what you are trying to create even once you
know how to do it. The same goes for the parser - what does a good AST for
antlr look like? I understand this kind of knowledge mostly comes from hard
earned experience, but rough guidelines can be very helpful.

Anyway, hanging out here and reading the archives has been very helpful, esp
when people are giving opinions as well as syntax. Nothing like listening to
experts in the end : ).

Thanks again,
Robin


----- Original Message -----
From: <mzukowski at yci.com>
To: <antlr-interest at yahoogroups.com>
Sent: Thursday, March 04, 2004 11:57 AM
Subject: RE: [antlr-interest] nesting rules, getting rule text


> Yeah, it seems people need a guide to reading the code sometimes.  This
> stuff is in Ter's lectures, but maybe something that pointed out
techniques
> used in the examples would be helpful too for those of you who just start
> hacking away?
>
> Monty
>
> -----Original Message-----
> From: Robin Debreuil [mailto:robin at debreuil.com]
> Sent: Thursday, March 04, 2004 9:49 AM
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] nesting rules, getting rule text
>
> Great Monty, thanks - these little tips of yours are really helpful to
those
> of us running blind here : ). I will structure things that way then...
>
> Cheers,
> Robin
>
>
> ----- Original Message -----
> From: <mzukowski at yci.com>
> To: <antlr-interest at yahoogroups.com>
> Sent: Thursday, March 04, 2004 11:25 AM
> Subject: RE: [antlr-interest] nesting rules, getting rule text
>
>
> > Yeah, typically you wouldn't nest at each DOT, you would have one root
and
> > then all the DOT WHATEVERs as children.  The java grammar or C grammar
> > should have examples of this.
> >
> > Monty
> >
> > -----Original Message-----
> > From: Robin Debreuil [mailto:robin at debreuil.com]
> > Sent: Thursday, March 04, 2004 2:30 AM
> > To: antlr-interest at yahoogroups.com
> > Subject: Re: [antlr-interest] nesting rules, getting rule text
> >
> > Hmm, I got it to work like:
> >
> > primary_expression!
> > { AST curAst = null;}
> >  :    ps:primary_start
> >       {curAst = ps_AST;}
> >      (
> >          ma:member_access
> >             {     curAst.setFirstChild(ma_AST);
> >                    curAst=ma_AST;
> >             }
> >      )*
> >     {#primary_expression = #ps;}
> >  ;
> >
> > Maybe there is an easier way? Maybe I 'dont want' this in the first
> > place...?
> >
> > Cheers,
> > Robin
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
> 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