|How to improve the error handling of my scanner? email@example.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)|
|From:||Hans-Peter Diettrich <DrDiettrich1@aol.com>|
|Date:||Tue, 13 Jan 2009 03:58:25 +0100|
|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>.
Return to the
Search the comp.compilers archives again.