Re: "Near Miss" error handling?

Scott Moore <samiam@cisco.com>
31 Mar 2001 02:43:19 -0500

          From comp.compilers

Related articles
"Near Miss" error handling? gwyn@thislove.dyndns.org (2001-03-27)
Re: "Near Miss" error handling? jbeniston@siroyan.com (Jon Beniston) (2001-03-28)
Re: "Near Miss" error handling? eeide@cs.utah.edu (Eric Eide) (2001-03-31)
Re: "Near Miss" error handling? eballen1@qwest.net (Bruce Ediger) (2001-03-31)
Re: "Near Miss" error handling? guerby@acm.org (Laurent Guerby) (2001-03-31)
Re: "Near Miss" error handling? samiam@cisco.com (Scott Moore) (2001-03-31)
Re: "Near Miss" error handling? Martin.Ward@durham.ac.uk (2001-03-31)
Re: "Near Miss" error handling? ian.trudel@tr.cgocable.ca (Ian Trudel) (2001-03-31)
Re: "Near Miss" error handling? joachim_d@gmx.de (Joachim Durchholz) (2001-04-04)
Re: "Near Miss" error handling? joachim_d@gmx.de (Joachim Durchholz) (2001-04-04)
Re: "Near Miss" error handling? uabbwat@uab.ericsson.se (Barry Watson) (2001-04-04)
Re: "Near Miss" error handling? ralph@inputplus.demon.co.uk (2001-04-14)
[4 later articles]
| List of all articles for this month |
From: Scott Moore <samiam@cisco.com>
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 samiam@cisco.com


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.