Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #1212 > unrolled thread

Error message with bison and flex

Started bylaplante.p@gmail.com
First post2014-04-07 22:36 -0700
Last post2014-04-12 03:31 +0000
Articles 4 — 4 participants

Back to article view | Back to comp.compilers


Contents

  Error message with bison and flex laplante.p@gmail.com - 2014-04-07 22:36 -0700
    Re: Error message with bison and flex Kaz Kylheku <kaz@kylheku.com> - 2014-04-10 15:06 +0000
      Re: Error message with bison and flex Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2014-04-11 03:30 +0200
        Re: Error message with bison and flex glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-12 03:31 +0000

#1212 — Error message with bison and flex

Fromlaplante.p@gmail.com
Date2014-04-07 22:36 -0700
SubjectError message with bison and flex
Message-ID<14-04-005@comp.compilers>
Sometime the text return from a syntax error is very short.

I would like to output 5 lines before the error and
5 lines after the error.

Is this possible without affecting the error message.

If I used input to read the next 5 lins, the message won't be the same and
I don't want to always accumulate the 5 lines before, it will add a lot of overhead to the lexical analyser.

Tx
[The way I'd do it would be to write my own YY_INPUT() that slurps in
the whole file to a buffer when it starts and hands the input to the
lexer a line at a time, so it knows what line it's on.  If there's an
error, it can then scan forward and backward in the file buffer to find
the five lines each way. -John]

[toc] | [next] | [standalone]


#1214

FromKaz Kylheku <kaz@kylheku.com>
Date2014-04-10 15:06 +0000
Message-ID<14-04-007@comp.compilers>
In reply to#1212
On 2014-04-08, laplante.p@gmail.com <laplante.p@gmail.com> wrote:
> Sometime the text return from a syntax error is very short.

Usually, there is little or no program text at all in a syntax error message.

> I would like to output 5 lines before the error and
> 5 lines after the error.

I don't see the point of this.

Just output errors in a way that an IDE can understand, so you can navigate
through errors visually. Then you have all the lines you want before and after
the error.

Speaking for myself, but I suspect the majority of others, programmers do not
want the error output of a compiler inflated by an order of magnitude with
snippets of the source code.
[People do use lex, yacc, et  al for other things than compilers that run under IDEs. -John]

[toc] | [prev] | [next] | [standalone]


#1215

FromHans-Peter Diettrich <DrDiettrich1@aol.com>
Date2014-04-11 03:30 +0200
Message-ID<14-04-008@comp.compilers>
In reply to#1214
Kaz Kylheku schrieb:
> On 2014-04-08, laplante.p@gmail.com <laplante.p@gmail.com> wrote:
>> Sometime the text return from a syntax error is very short.
>
> Usually, there is little or no program text at all in a syntax error message.
>
>> I would like to output 5 lines before the error and
>> 5 lines after the error.
>
> I don't see the point of this.

Me2

> Just output errors in a way that an IDE can understand, so you can navigate
> through errors visually. Then you have all the lines you want before and after
> the error.

> [People do use lex, yacc, et  al for other things than compilers that run under IDEs. -John]

In these cases the "source code" display may be even less helpful. IMO
every application using parsers needs its kind of an IDE, that
translates the syntactical errors into something meaningful to the user.

DoDi
[People do use the -C5 flag to grep. -John]

[toc] | [prev] | [next] | [standalone]


#1216

Fromglen herrmannsfeldt <gah@ugcs.caltech.edu>
Date2014-04-12 03:31 +0000
Message-ID<14-04-009@comp.compilers>
In reply to#1215
Hans-Peter Diettrich <DrDiettrich1@aol.com> wrote:

(snip)

> In these cases the "source code" display may be even less helpful. IMO
> every application using parsers needs its kind of an IDE, that
> translates the syntactical errors into something meaningful to the user.

When I first started programming, with OS/360 compilers, it was usual
for the compiler to print an annotated listing file with some type of
numbering. Ones I remember printed ISN (internal statement number)
instead of input file line numbers, which you could match up on the
listing.

Fortran G prints a $ in the suspected error column on the next line,
where Fortran H gives the column number.

I suppose the printed listing file has some similarity to the full
screen display in an IDE.

The listing file also could contain a list of variables with their
address and line number in which they were used.

With cards, you had to print the file and look at it. With WYLBUR, you
could fetch the file back to an editing session, search through it
using editor command, such as search for the word ERROR, then purge
the file without printing it.

I don't know if any compilers still generate listing files with line
numbers and cross references.

-- glen

[toc] | [prev] | [standalone]


Back to top | Article view | comp.compilers


csiph-web