Related articles |
---|
error recovering l41484@alfa.ist.utl.pt (Umm) (1997-04-16) |
From: | Umm <l41484@alfa.ist.utl.pt> |
Newsgroups: | comp.compilers |
Date: | 16 Apr 1997 00:26:28 -0400 |
Organization: | Compilers Central |
Keywords: | yacc, errors, question |
How can i recover from a error which, doesn't have a "terminator"??
Where is the problem:
suppose we have a language which must begin with a 'begin'
so we have the start symbol:
program : BEGIN
blah blah
END_PROGRAM
| error {print msg that says that program MUST begin
with a begin}
;
this works, but the program NEVER recovers. it keeps saying, must begin
with BEGIN no matter what is issued.
examples:
ee
begin
doesn't work. :-(
Any thoughts????
Tiago Umm Pascoal
l41484@alfa.ist.utl.pt
[Yacc's approach to error recovery is to throw tokens away, so you need to
add error rules that provide the tokens you need, e.g.:
end_token: END_PROGRAM | error ;
-John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.