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) |
From: | John Williams <johnwilliams40@live.com> |
Newsgroups: | comp.compilers |
Date: | Sat, 10 Jan 2009 19:27:31 +0100 |
Organization: | Compilers Central |
Keywords: | parse, errors, question |
Posted-Date: | 12 Jan 2009 15:26:06 EST |
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.
I thought of adding a PRAGMA section to my ATG Grammar that tells Coco/R if a
string matches a bad identifier pattern, the compiler prints "Bad identifier"
using the console.
Are there better ways to achieve this?
Thanks,
Return to the
comp.compilers page.
Search the
comp.compilers archives again.