Recovering from missing tokens

Lujop <>
17 Nov 2004 11:44:16 -0500

          From comp.compilers

Related articles
Recovering from missing tokens (Lujop) (2004-11-17)
Re: Recovering from missing tokens (2004-11-19)
Re: Recovering from missing tokens (Lujop) (2004-11-20)
| List of all articles for this month |

From: Lujop <>
Newsgroups: comp.compilers
Date: 17 Nov 2004 11:44:16 -0500
Organization: Compilers Central
Keywords: parse, errors
Posted-Date: 17 Nov 2004 11:44:16 EST


I have a pseudocode language similar to java. Now I want to start the
syntactic error checks and recovery. I use ANTLR (a descendent
parser) and I use a lookahead of 1 token. ANTLR uses exceptions as
the error mechanism and launch an exception as fast as it knows the

If I have:


              CONST1:integer=10 //CONST1 is an ident

              a:integer //a is an identifier
//Start of code for exemple an assignment
a:=10 //a is an identifier


If for example the user forgot to put the const token. What is the
best way to solve the error and recovery from it?

Because the parser gets CONST1 (an identifier) and put the parser in
the code rule (the assignment rule) . And then I think that is very
hard to recovery.

A lot of thanks in advance,
[I saw a lot of work in the 1970s on parsers that would attempt to correct
erroneous program syntax. As far as I can tell, nobody bothers any more.
It never worked very well, and its appeal is a lot less when the time
to rerun the compiler is two seconds rather than two hours. -John]

Post a followup to this message

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