Re: How to improve the error handling of my scanner?

Hans-Peter Diettrich <DrDiettrich1@aol.com>
Tue, 13 Jan 2009 03:58:25 +0100

          From comp.compilers

Related articles
How to improve the error handling of my scanner? johnwilliams40@live.com (John Williams) (2009-01-10)
Re: How to improve the error handling of my scanner? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-01-13)
| List of all articles for this month |
From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: Tue, 13 Jan 2009 03:58:25 +0100
Organization: Compilers Central
References: 09-01-019
Keywords: parse, errors
Posted-Date: 13 Jan 2009 07:32:05 EST

John Williams schrieb:


> I finally built my scanner and parser using Coco/R, but I need some help to
> improve error handling.
>
> For example, I tried to parse the following program:
>
> MODULE Program;
> VAR 4fgnn : INTEGER;
> END Program.
>
> There's obviously an error with "4fgnn", it is a bad identifier because it
> starts by a number. This is the compiler output:
>
> line 2 col 12: "END" expected
>
> Of course it detects the error, but it is kind of vague.


It's a matter of your grammar, what errors can be caught in which places.


When "4fgnn" is scanned as a number and an identifier token, no rule
should exist that accepts a sequence of "VAR" <number>.


DoDi



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.