[antlr-interest] header sections (was: Re: ANTLR for Python)

lgcraymer lgc at mail1.jpl.nasa.gov
Wed Nov 17 17:06:26 PST 2004



The "header" section dates back to the earliest versions of PCCTS that
I worked with.  There it was a place to put "C" includes, not for
actionable code.  That model works for Java, C++, and C# as well.

For Marq's problem, I think that it would be better to have an
optional "init" section in addition to any header section(s).  That
would fit other languages with module initialization code (if I
remember right, OCaml needs something like that).  The big advantage
would be to keep the declaration semantics of the "header" separate
from the executable semantics of initialization.

--Loring


--- In antlr-interest at yahoogroups.com, Ric Klaren <ric.klaren at g...> wrote:
> Hi,
> 
> On Wed, 17 Nov 2004 21:27:37 -0000, Marq Kole <marq.kole at p...> wrote:
> > > 2 lexers in one .g is not possible. Your idea will work I guess
> > although
> > > moving some stuff around might be prettier. Hmm might also need
> > some fixing
> > > in antlr.g.
> > 
> > Moving things around in the .g files is going to be hard if you do
> > not want to break existing code. Maybe that is something to consider
> > when doing ANTLR 3.
> 
> It is probably possible to move the headersections into the classDef
> rule that way there could be header sections for each
> lexer/parser/treeparser in a rule. I think it would be mostly
> backwards compatible. The normal header section (without name) should
> probably be treated in the old way and the rest on per
> lexer/parser/treeparser basis.
> 
> Since noone ran into this before I guess it's just as good to mark it
> in the docs. Your workaround doesn't look bad. Although I could expect
> some minor problems if you also implemented the namespace options in
> python (erm do those exist in python?).
> 
> It's definitely something that should be done right in antlr3.
> (they're not implemented yet there I think)
> 
> Cheers,
> 
> Ric





 
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