[antlr-interest] Preserving whitespace

Bogdan Mitu bogdan_mt at yahoo.com
Thu Jun 13 03:43:51 PDT 2002


Hi,

I'm doing something along the lines of the "Preserve whitespace" example
from ANTLR distribution. Take the AST, and write it back with small changes.
The example is very useful, but ... in practice you don't have only tokens
ignored before the parser, you also ignore some in parser rules. For
instance, in the "Preserve whitespace" example one would normally ignore
SEMI while constructing the AST:

stat : ID ASSIGN^ expr SEMI! ;   // see the ! after SEMI
  
Now SEMI is not present in the AST, and I don't know how can I retrieve
hidden tokens before/after SEMI. In an ideal world, I would like to have
SEMI treated exactly as it was ignored before the parser, just like an other
hidden token. But it seems that SEMI is lost after the parser, together with
its hidden tokens.

If I'm wrong, please correct me, it will save me a lot of time.

Best regards,
Bogdan


--- Terence Parr <parrt at jguru.com> wrote:
>  From Erik Hatcher...a few comments on Ant.
> 
> Begin forwarded message:
> 
> > From: "Erik Hatcher" <erik at hatcher.net>
> >> On Tuesday, June 11, 2002, at 06:19  AM, Bogdan Mitu wrote:
> >>> Just incidentally, the next incarnation of Ant (Ant 2) will be
> >>> independent
> >>> of XML or other particular encoding, which I think it's a step in the
> >>> right
> >>> direction.
> >
> > Ant 1.5 actually has pluggable ProjectHelper capability to allow you to 
> > plug
> > in a class that constructs the Project object.  The default one builds 
> > it
> > from parsing an XML file, but you can now plug in your own.  Maybe you 
> > ANTLR
> > gurus could have one that takes a Makefile and constructs a Project 
> > object
> > :))
> >
> > This pluggable layer will be used, I think, to start providing XML 
> > namespace
> > support, but is much more generally capable than that.  One person I've 
> > seen
> > report that he's taken a project model (in XML) and XSLT'd it to a build
> > file on the fly when invoking Ant so that all he maintains are the 
> > project
> > model and XSLT, no build.xml.
> >
> >> For your info, Erik Hatcher, a cool cat that manages the Ant FAQ at
> >> jGuru, is done with his Ant book.  Should be out soon:
> >>
> >> Java Development with Ant by Erik Hatcher and Steve Loughran
> >> ISBN 1930110-588 -- will be published August 1st
> >> Softbound, 450 pages, $44.95
> >
> > And this is really going to be about 600+ pages - Manning has just never
> > updated their info on our latest page count!  And yes, my fingers are 
> > tired.
> >
> >     Erik
> >
> >
> --
> Co-founder, http://www.jguru.com
> Creator, ANTLR Parser Generator: http://www.antlr.org
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

 

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



More information about the antlr-interest mailing list