help-flex
[Top][All Lists]
Advanced

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

Re: Location revisited, column tracking...


From: John Millaway
Subject: Re: Location revisited, column tracking...
Date: Tue, 16 Jul 2002 08:43:02 -0700 (PDT)

> I would personally find it useful to have an extra option e.g. named %option
> yylocation that tells the scanner to keep track of the location.
> ...
> I'm aware that it may be difficult to implement - but I dont think it's
> impossible. 

It is very easy to implement. The debate was not over locations, but whether or
not flex should do your work for you, whether or not location tracking is
featuritis. I say flex should do it, and Akim says it shouldn't.

Case in point: I just added manual location tracking to a scanner/parser last
week. It took half a day, including debugging, to get all the lines and columns
correct across multiple files. What a waste of time. And guess what? I used the
default bison yylloc definition. That means if flex had an option to perform
column tracking, I would have been done in half a minute instead of half a day.

> I'm also aware that even the todays implementation of %option
> yylineno may be considered faulty - depending on how you think it should
> work. The current documentation states nothing about that it will contain
> the line number of where the returned token was found!. The problem occurs
> e.g. in cases where the look ahead is forwarding over a new line character.
> But yet again this could be corrected at the same time (for the location at
> least).

This is not true.  yylineno is not affected by lookahead or backtracking.
However, yylineno is wacky if you match tokens across newlines (which is rare),
e.g., if "foo\nbar" is matched, then yylineno will contain the line number on
which  "bar" is found, not "foo".




__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com



reply via email to

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