help-flex
[Top][All Lists]
Advanced

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

Re: why are locations dictated by bison?


From: John W. Millaway
Subject: Re: why are locations dictated by bison?
Date: Sat, 12 Jan 2002 16:57:07 -0800 (PST)

> I suggest that you show me how you can simplify the following location
> tracking scanner, so that we can really compare the two methods.
> 
> Oh, watch out: here I use a C++ class to compute locations.  One
> location is composed of two Positions.  Of course, Flex must let me do
> that, just like Bison let's me use a C++ class here.

Here's how: Get rid of those macros and let flex do the location tracking its
own way. Use flex's struct in your parser, or copy flex's location data into
your custom location data.

My point is that perhaps you (Joe Developer) created your C++ location class
because flex did not offer that ability in the first place. Perhaps your
application would do just fine with flex's location tracking. Perhaps you
aren't a flex expert and don't go in for all the macro shenannigans. Or perhaps
you ARE a flex expert and know that your junior developers won't be able to
decipher your macro shennanigans.

Incidently, what does Bison do with that class anyway? What do you mean when
you say that bison "propogates" locations? I tried defining my own YYLTYPE, but
got compiler errors:

//usr/lib/bison.simple:567: structure has no member named `first_line'
//usr/lib/bison.simple:567: structure has no member named `first_line'
//usr/lib/bison.simple:568: structure has no member named `first_column'
//usr/lib/bison.simple:568: structure has no member named `first_column'
//usr/lib/bison.simple:569: structure has no member named `last_line'
//usr/lib/bison.simple:569: structure has no member named `last_line'
//usr/lib/bison.simple:570: structure has no member named `last_column'
//usr/lib/bison.simple:570: structure has no member named `last_column'
//usr/lib/bison.simple:571: structure has no member named `text'
//usr/lib/bison.simple:575: structure has no member named `last_line'
//usr/lib/bison.simple:575: structure has no member named `last_line'
//usr/lib/bison.simple:576: structure has no member named `last_column'
//usr/lib/bison.simple:576: structure has no member named `last_column'

Also, I'm sure you know this already, but the manual is not in sync with the
code. That's why I'm unclear on what's bison is supposed to be doing with
yylloc.


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/



reply via email to

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