Related articles |
---|
LEX/YACC - grammar problems and printing error messages nett@technix.mn.org (1992-05-28) |
Re: LEX/YACC - grammar problems and printing error messages johnl@iecc.cambridge.ma.us (1992-05-28) |
Re: LEX/YACC - grammar problems and printing error messages craig@comp.lancs.ac.uk (1992-05-29) |
LEX/YACC - grammar problems and printing error messages thiemann@informatik.uni-tuebingen.de (1992-06-02) |
Newsgroups: | comp.unix.programmer,comp.compilers |
From: | craig@comp.lancs.ac.uk (Criag Wylie) |
Keywords: | yacc, lex, errors |
Organization: | Department of Computing at Lancaster University, UK. |
References: | 92-05-148 |
Date: | Fri, 29 May 1992 11:08:17 GMT |
The easiest way I have found of associating erors with lines, which allows
for multiple errors on lines as well.
As soon as YACC detects an error it calls yyerror(). Change this to
create a linked list/array of error code/text and character position.
When an end of line is detected check to see if the error list is empty,
if it isn't print the line and then print each of the errors. The
character position allows you to position a marker on the line.
The down side of this is error cascading where one error causes a large
number of spurious errors to be seen as the grammar re-synchs with the
input.
Craig.
[This certainly works, though the original question was how to get a copy
of the entire input line from lex. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.