Re: Error handling with Coco/r

Glen Herrmannsfeldt <gah@ugcs.caltech.edu>
Sat, 06 Dec 2008 19:21:27 -0700

          From comp.compilers

Related articles
Error handling with Coco/r johnwilliams40@live.com (John Williams) (2008-12-07)
Re: Error handling with Coco/r gah@ugcs.caltech.edu (Glen Herrmannsfeldt) (2008-12-06)
Re: Error handling with Coco/r DrDiettrich1@aol.com (Hans-Peter Diettrich) (2008-12-07)
Re: Error handling with Coco/r gah@ugcs.caltech.edu (Glen Herrmannsfeldt) (2008-12-07)
Re: Error handling with Coco/r vrotaru.md@gmail.com (vrotaru.md@gmail.com) (2008-12-13)
| List of all articles for this month |

From: Glen Herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups: comp.compilers
Date: Sat, 06 Dec 2008 19:21:27 -0700
Organization: Aioe.org NNTP Server
References: 08-12-040
Keywords: errors, comment
Posted-Date: 07 Dec 2008 08:32:30 EST

John Williams wrote:
> I'm using the tool Coco/r to build a grammar for a programming
> language. My token section is something like this:


> id = letter { letter | digit }.
> integer = digit { digit } | digit { hexDigit } "H".


> The problem is that a wrong hexadecimal number in an assignment such
> as "a := 32GH;" is identified as an error by the syntax analyzer. I
> would like to produce a more meaningful message such as "invalid
> hexadecimal" so I think I need to detect errors at lexer level. Is
> there any option in Coco/r or should I have to modify the scanner by
> hand?


That will be pretty hard to do in general. Not so bad if you
just want to add letters, but say you find:


        a := (32)H)


That is the illegal hex digit ). That is one way to read it, but
it could also be (32) followed by an illegal H).


It might be that with dynamic programming you can find the parse that
minimizes the number of characters that need to be changed, and then
report the error based on that.


For most people and most languages, if you get close the person will
figure it out much easier than the computer.


-- glen
[Back in the 1970s there was a lot of work on automatic error correction,
which was of some interest when compilers ran as batch jobs and you wanted
to get as much out of each job as possible. I agree that these days once
you've pointed out where the error was, there's little point in doing any
more work. -John]


Post a followup to this message

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