[Top][All Lists]

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

Re: Flex/Bison standardized diagnostics

From: Hans Aberg
Subject: Re: Flex/Bison standardized diagnostics
Date: Mon, 7 Jan 2002 15:54:21 +0100

At 16:11 +0100 2002/01/04, Hans Aberg wrote:
>- Begin and end (line number, column number) pairs.
>- Begin and end stream position number.
>- A pointer to the context of the diagnostics, for example the lines
>containing the location, or as much of it as is buffered. One option might
>be to strip initial whitespace, also giving the initial location of its

If one should be able to compute the many different variations that Akim
suggested while keeping the lexer overhead down to a minimum in the scan, I
arrive at that one should record for a character position:

- The line count.
- The position number of the beginning of the line, and a pointer to it in
the lexer buffer (to the character after the last character of the newline).
- The position number of the character itself.

Then, for every token read, for its location one records this data in C/C++
semi-open interval [begin, end) paradigm style.

Given that, the other ways to locate the error token and location should be
computable at error time. And the cost of recording this information during
scan would be kept at a minimum.

If a user does not need all information, one might have options cutting it
down, but I think that if the compiler is able to put these numbers into
registers, keeping track of them will not generate much overhead.

Then tuning it together with Bison's location feature would be suitable,
because then the parser would neither record anything but the essentials
needed at any eventual error time.

The problem I do not see how to solve is if the lexer changes its buffer,
because then the pointer to the beginning of the line becomes invalid.

  Hans Aberg

reply via email to

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