error recovering

Umm <>
16 Apr 1997 00:26:28 -0400

          From comp.compilers

Related articles
error recovering (Umm) (1997-04-16)
| List of all articles for this month |

From: Umm <>
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
                  | 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.



doesn't work. :-(

Any thoughts????

                                                  Tiago Umm Pascoal
[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 ;



Post a followup to this message

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