Re: "Near Miss" error handling?

Scott Moore <>
31 Mar 2001 02:43:19 -0500

          From comp.compilers

Related articles
"Near Miss" error handling? (2001-03-27)
Re: "Near Miss" error handling? (Jon Beniston) (2001-03-28)
Re: "Near Miss" error handling? (Eric Eide) (2001-03-31)
Re: "Near Miss" error handling? (Bruce Ediger) (2001-03-31)
Re: "Near Miss" error handling? (Laurent Guerby) (2001-03-31)
Re: "Near Miss" error handling? (Scott Moore) (2001-03-31)
Re: "Near Miss" error handling? (2001-03-31)
Re: "Near Miss" error handling? (Ian Trudel) (2001-03-31)
Re: "Near Miss" error handling? (Joachim Durchholz) (2001-04-04)
Re: "Near Miss" error handling? (Joachim Durchholz) (2001-04-04)
Re: "Near Miss" error handling? (Barry Watson) (2001-04-04)
Re: "Near Miss" error handling? (2001-04-14)
[4 later articles]
| List of all articles for this month |

From: Scott Moore <>
Newsgroups: comp.compilers
Date: 31 Mar 2001 02:43:19 -0500
Organization: Cisco Systems Inc.
References: 01-03-135
Keywords: parse, errors, editor
Posted-Date: 31 Mar 2001 02:43:19 EST

Gwyn Judd wrote:

> I'm writing (modifying actually) a compiler for my final undergraduate
> project and I've come across a feature I've never seen in a production
> compiler. basically when the compiler comes across an identifier it
> hasn't seen before, it will go through the list of known identifiers
> and try to determine which is the closest so it can then make a
> hopefully helpful suggestion on how to correct the error. I didn't

Most of these routines are dramatically simple, and the technique is
covered in the compiler construction books. Given an undefined label,
the checker tries to check for:

1. One character wrong.

2. One character missing.

3. One character added.

4. Two adjacent characters transposed.

It was suposedly based on a study of common identifier errors. You
need to except one and probably two character identifiers from the
system, since they will yield false results. The routine I use for
this is pretty small, it just takes the match string, mangles it in
the above ways, then runs a search again and iterates for every
character, based on the idea that having an error is not common, so
does not need a blindingly fast algorithim. You might also want to
flag the labels as respelled, to cut down on double errors.

Scott A. Moore is

I don't have a solution, but I admire your problem.

Post a followup to this message

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