help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make Bison disregard tokens?


From: Edsko de Vries
Subject: Re: How to make Bison disregard tokens?
Date: Fri, 2 Mar 2007 13:54:40 +0000
User-agent: Mutt/1.5.9i

On Fri, Mar 02, 2007 at 02:43:19PM +0100, address@hidden wrote:
> On Friday 02 March 2007 13:39, Edsko de Vries wrote:
> > On Fri, Mar 02, 2007 at 01:17:04PM +0100, address@hidden wrote:
> > > On Friday 02 March 2007 13:01, Edsko de Vries wrote:
> > > > Well, no, that's the point. Blank lines should be recorded as NOPs
> > > > where possible, so that we know where they are and unparse them.
> > >
> > > Can you reveal some details regarding what you are trying to do ?
> >
> > I am working on the front end of phc, an open source framework for
> > working on PHP scripts (and hopefully ultimately compiling PHP to native
> > machine code-we're getting there).
> thanks for explaining this.
> > One such program is an unparser that takes a PHP script in our abstract
> > representation, and dumps it back to PHP syntax (a pretty printer). This
> > is useful because after transforming your PHP script (for example, doing
> > some refactoring), you may want to output it again and run it.
> in this case you should try to look at location tracking features for each 
> token. 
> I think this will solve your problems, and further will not clutter up your 
> grammar file with white-space handling.

Yes, proper location tracking would solve this problem. I had been
working on that, but found it quite difficult to get working. The bison
end is not so hard, as it has built-in support for location tracking,
but modifying the lexer (generated by flex) to generate the right
location information in the first place is non-trivial. If you have a
good solution for that, I'd be very interested to hear it!

Thanks,

Edsko




reply via email to

[Prev in Thread] Current Thread [Next in Thread]