[antlr-interest] A few ANTLR 3.0b4 questions
Foolish Ewe
foolishewe at hotmail.com
Fri Nov 17 11:03:42 PST 2006
Thanks Michael:
This is very helpful.
Regarding the @header{} section, this appears to only show up in the parser,
so I think I need to copy the body and wrap it with an @lexer::header{}
section.
Is there some way that I can avoid having two separate headers. I also
noticed that changing
the package name has introduced some problems when trying to run the
debugging environment.
I've gotten to the point where the ANTLR part of the code is large enough we
want to split
it (to allow a colleague to collaborate with me on the remaining section).
So now we want
to use separate compilation, and we want the language recognition and high
level processing
to be an a "frontend" namespace, say "myproject.frontend" while some of the
library
support routines and run time environment would exist in a "backend" name
space,
say "myproject.backend".
When I went to debug the "frontend", I get a popup saying "Compler Failed
with result code 1".
The console shows a bunch of errore messages in class __Test__ that indicate
that
the Main generated by the debugger cannot locate the parser class nor can
the compiler
find the lexer class. If I comment out the headers with the package name
messages, the
error goes away.
I suspect this is a namespace issue, does anyone know a fix for it?
Thanks:
Bill M.
>From: "Micheal J" <open.zone at virgin.net>
>To: <antlr-interest at antlr.org>
>Subject: Re: [antlr-interest] A few ANTLR 3.0b4 questions
>Date: Thu, 16 Nov 2006 03:04:41 -0000
>
>Hi,
>
>[...]
>
> > 2) I am using an AST but for some reason, neither @header{}
> > @members{} seem
> > to have the deisred behavior as appears to be
> > indicated in the wiki nor does header{} appear to work.
> > I want to set
> > the java package
> > name and perhaps use some imported libraries.
> >
> > The relevant syntax looks like:
> > grammar MyGrammar;
> >
> > options{
> > output=AST;
> > }
> >
> > /* This won't compile
> > @header{
> > package mypackage;
> > }
>
>[...]
>
> > tokens{
> > // This all works.
> > }
>
>@header{...}, @members{...} etc blocks cannot appear before tokens{...}
>block.
>
> > 3) I would like to add some Java source to invoke some actions in my
> > grammar.
> > Do I need code to walk the AST, or can I try to
> > accomplish them during
> > the AST
> > construction phase, I expect I'll be using both inherited
> > and synthetic
> > attributes in my rules.
>
>Depends on your language. Some language do not lend themselves to
>"single-phase" processing tools. Using an independent TreeParser is
>"cleaner" but less performant.
>
> > If I have a rule like
> >
> > command:
> > (
> > c1=commandType1->(COMMAND $c1) // Here I would like
> > java code for
> > command processing
> > |
> > c2=commandType2->(COMMAND $c2) // Here too
> > );
> >
> > I took a quick look at the wiki and it appears there is some
> > @actions stuff
> > but I don't grok it yet.
>
>Have a look at the source code in the samples. And at the mantra project
>sources too.
>
>
>Micheal
>
>-----------------------
>The best way to contact me is via the list/forum. My time is very limited.
>
_________________________________________________________________
All-in-one security and maintenance for your PC. Get a free 90-day trial!
http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http://clk.atdmt.com/MSN/go/msnnkwlo0050000001msn/direct/01/?href=http://www.windowsonecare.com/?sc_cid=msn_hotmail
More information about the antlr-interest
mailing list