error recovery with yacc

scheek@RUGRCX.RUG.NL (Frans van hoesel)
Tue, 10 Nov 1992 16:14:41 GMT

          From comp.compilers

Related articles
error recovery with yacc scheek@RUGRCX.RUG.NL (1992-11-10)
Re: error recovery with yacc (1992-11-14)
| List of all articles for this month |

Newsgroups: comp.compilers
From: scheek@RUGRCX.RUG.NL (Frans van hoesel)
Organization: Compilers Central
Date: Tue, 10 Nov 1992 16:14:41 GMT
Keywords: yacc, errors


      I have a problem understanding/using the error recovery mechanisme
      with yacc. Part of my syntax is:

     %start compilation_chunk

: PROC proc_header proc_body ENDPROC
: statement_list
: /* empty */
| statement
| statement_list separator
| statement_list separator statement
: ';'
: /* empty */
| statement
| one_liner ';'
| one_liner ';' statement
: one_liner NEWLINE
| procedure

      If some statement is in error then I just want to skip over the
      next separator (which is a ';' or NEWLINE) and continue the
      parsing of the proc_body with the rest of the statements.
      I added the following rule to the statement_list definition:
| error separator statement_list
      ( no yyerrok here!)
      This seems ok, but causes the error to be reduce only just before
      the ENDPROC.
      Somehow it just doesn't feel right to me. Is there a better way?

      It sounds to me I'm reinventing the wheel, so maybe there is a
      kind person who wants to explain to me how a wheel should look like?

-- frans van hoesel or
(both are me)

Post a followup to this message

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