From 99ac23b4b4d8b18acbb27c8bd4e35f2213c8e8e7 Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 21 Feb 1997 17:11:04 +0000 Subject: [PATCH] Additions for non-correcting error recovery --- lang/cem/cemcom.ansi/LLmessage.c | 6 ++++++ lang/cem/cemcom.ansi/declar.g | 4 ++++ lang/cem/cemcom.ansi/proto.make | 5 +++-- lang/cem/cemcom/LLmessage.c | 6 ++++++ lang/cem/cemcom/declar.g | 4 ++++ lang/cem/cemcom/expression.g | 2 ++ lang/cem/cemcom/proto.make | 5 +++-- lang/m2/comp/LLmessage.c | 12 ++++++++++-- lang/m2/comp/program.g | 9 +++++++-- lang/m2/comp/proto.make | 5 +++-- lang/m2/comp/statement.g | 3 ++- 11 files changed, 50 insertions(+), 11 deletions(-) diff --git a/lang/cem/cemcom.ansi/LLmessage.c b/lang/cem/cemcom.ansi/LLmessage.c index 4c08480d2..c88c5eb24 100644 --- a/lang/cem/cemcom.ansi/LLmessage.c +++ b/lang/cem/cemcom.ansi/LLmessage.c @@ -19,11 +19,17 @@ LLmessage(tk) { error("end of file expected"); } else if (tk) { +#ifndef LLNONCORR error("%s missing before %s", symbol2str(tk), symbol2str(DOT)); +#endif insert_token(tk); } else { +#ifndef LLNONCORR error("%s deleted", symbol2str(DOT)); +#else + error("%s not expected", symbol2str(DOT)); +#endif } tk_nmb_at_last_syn_err = token_nmb; } diff --git a/lang/cem/cemcom.ansi/declar.g b/lang/cem/cemcom.ansi/declar.g index a60851b6b..4322cbeb0 100644 --- a/lang/cem/cemcom.ansi/declar.g +++ b/lang/cem/cemcom.ansi/declar.g @@ -145,6 +145,7 @@ single_decl_specifier /* non_empty */ (register struct decspecs *ds;) ds->ds_typedef = 1; } | + %erroneous IDENTIFIER { error("%s is not a type identifier", dot.tk_idf->id_text); @@ -154,6 +155,9 @@ single_decl_specifier /* non_empty */ (register struct decspecs *ds;) dot.tk_idf->id_def->df_sc = TYPEDEF; } } +| + %illegal + IDENTIFIER | struct_or_union_specifier(&ds->ds_type) | diff --git a/lang/cem/cemcom.ansi/proto.make b/lang/cem/cemcom.ansi/proto.make index cfde681d2..a23d11fc6 100644 --- a/lang/cem/cemcom.ansi/proto.make +++ b/lang/cem/cemcom.ansi/proto.make @@ -12,7 +12,7 @@ SRC_DIR = \ TABGEN= $(UTIL_BIN)/tabgen LLGEN = $(UTIL_BIN)/LLgen LLGENOPTIONS = \ - -v + -n SRC_G = $(SRC_DIR)/program.g $(SRC_DIR)/declar.g \ $(SRC_DIR)/expression.g $(SRC_DIR)/statement.g $(SRC_DIR)/ival.g @@ -64,7 +64,7 @@ SRC_C = \ $(SRC_DIR)/type.c \ $(SRC_DIR)/util.c GEN_C = tokenfile.c program.c declar.c expression.c statement.c ival.c \ - symbol2str.c char.c Lpars.c next.c + symbol2str.c char.c Lpars.c next.c Lncor.c CFILES= $(SRC_C) $(GEN_C) SRC_H = \ @@ -196,6 +196,7 @@ clean: LLfiles: $(GFILES) $(LLGEN) $(LLGENOPTIONS) $(GFILES) @touch LLfiles + @if [ -f Lncor.c ] ; then : ; else touch Lncor.c ; fi hfiles: Parameters $(SRC_DIR)/make.hfiles $(SRC_DIR)/make.hfiles Parameters diff --git a/lang/cem/cemcom/LLmessage.c b/lang/cem/cemcom/LLmessage.c index ebfe980b1..edc7d0ec7 100644 --- a/lang/cem/cemcom/LLmessage.c +++ b/lang/cem/cemcom/LLmessage.c @@ -20,11 +20,17 @@ LLmessage(tk) { error("end of file expected"); } else if (tk) { +#ifndef LLNONCORR error("%s missing before %s", symbol2str(tk), symbol2str(DOT)); +#endif insert_token(tk); } else { +#ifndef LLNONCORR error("%s deleted", symbol2str(DOT)); +#else + error("%s not expected", symbol2str(DOT)); +#endif } tk_nmb_at_last_syn_err = token_nmb; } diff --git a/lang/cem/cemcom/declar.g b/lang/cem/cemcom/declar.g index 8c377667a..f8bb113e3 100644 --- a/lang/cem/cemcom/declar.g +++ b/lang/cem/cemcom/declar.g @@ -134,6 +134,7 @@ single_type_specifier(register struct decspecs *ds;): %default TYPE_IDENTIFIER /* this includes INT, CHAR, etc. */ {idf2type(dot.tk_idf, &ds->ds_type);} | + %erroneous IDENTIFIER { error("%s is not a type identifier", dot.tk_idf->id_text); @@ -143,6 +144,9 @@ single_type_specifier(register struct decspecs *ds;): dot.tk_idf->id_def->df_sc = TYPEDEF; } } +| + %illegal + IDENTIFIER | struct_or_union_specifier(&ds->ds_type) | diff --git a/lang/cem/cemcom/expression.g b/lang/cem/cemcom/expression.g index 276b01d47..0c4ff2694 100644 --- a/lang/cem/cemcom/expression.g +++ b/lang/cem/cemcom/expression.g @@ -23,6 +23,8 @@ extern struct expr *intexpr(); primary(register struct expr **expp;) : IDENTIFIER {dot2expr(expp);} +| + %illegal TYPE_IDENTIFIER | constant(expp) | diff --git a/lang/cem/cemcom/proto.make b/lang/cem/cemcom/proto.make index 0df00cfeb..8ad2c41ff 100644 --- a/lang/cem/cemcom/proto.make +++ b/lang/cem/cemcom/proto.make @@ -12,7 +12,7 @@ SRC_DIR = \ TABGEN= $(UTIL_BIN)/tabgen LLGEN = $(UTIL_BIN)/LLgen LLGENOPTIONS = \ - -v + -n SRC_G = $(SRC_DIR)/program.g $(SRC_DIR)/declar.g \ $(SRC_DIR)/expression.g $(SRC_DIR)/statement.g $(SRC_DIR)/ival.g @@ -64,7 +64,7 @@ SRC_C = \ $(SRC_DIR)/stab.c GEN_C = tokenfile.c program.c declar.c expression.c statement.c ival.c \ - symbol2str.c char.c Lpars.c next.c + symbol2str.c char.c Lpars.c next.c Lncor.c CFILES= $(SRC_C) $(GEN_C) SRC_H = \ @@ -193,6 +193,7 @@ clean: LLfiles: $(GFILES) $(LLGEN) $(LLGENOPTIONS) $(GFILES) @touch LLfiles + @if [ -f Lncor.c ] ; then : ; else touch Lncor.c ; fi hfiles: Parameters $(SRC_DIR)/make.hfiles $(SRC_DIR)/make.hfiles Parameters diff --git a/lang/m2/comp/LLmessage.c b/lang/m2/comp/LLmessage.c index 6f6de9374..f8bc0cc43 100644 --- a/lang/m2/comp/LLmessage.c +++ b/lang/m2/comp/LLmessage.c @@ -34,7 +34,9 @@ LLmessage(tk) */ register t_token *dotp = ˙ +#ifndef LLNONCORR error("%s missing before %s", symbol2str(tk), symbol2str(dotp->tk_symb)); +#endif aside = *dotp; @@ -62,9 +64,15 @@ LLmessage(tk) } } else if (tk < 0) { - error("garbage at end of program"); + error("end of file expected"); + } + else { +#ifndef LLNONCORR + error("%s deleted", symbol2str(dot.tk_symb)); +#else + error("%s not expected", symbol2str(dot.tk_symb)); +#endif } - else error("%s deleted", symbol2str(dot.tk_symb)); tk_nmb_at_last_syn_err = token_nmb; } diff --git a/lang/m2/comp/program.g b/lang/m2/comp/program.g index 95ec04c8e..a83b8a148 100644 --- a/lang/m2/comp/program.g +++ b/lang/m2/comp/program.g @@ -109,7 +109,9 @@ import(int local;) name, otherwise the names in the import list are module names. */ [ FROM - IDENT { FromId = dot2leaf(Name); + IDENT + %substart DefinitionModule; + { FromId = dot2leaf(Name); if (local) { df = lookfor(FromId,enclosing(CurrVis),0,D_USED); } @@ -117,6 +119,7 @@ import(int local;) } ]? IMPORT IdentList(&ImportList) ';' + %substart DefinitionModule; { if (FromId) { EnterFromImportList(ImportList, df, FromId); } @@ -226,7 +229,9 @@ ProgramModule register t_def *df; } : MODULE - IDENT { + IDENT + %substart DefinitionModule; + { if (state == IMPLEMENTATION) { int len = strlen(dot.TOK_IDF->id_text); diff --git a/lang/m2/comp/proto.make b/lang/m2/comp/proto.make index 9ccef6adf..e544e84ca 100644 --- a/lang/m2/comp/proto.make +++ b/lang/m2/comp/proto.make @@ -12,7 +12,7 @@ SRC_DIR = \ TABGEN= $(UTIL_BIN)/tabgen LLGEN = $(UTIL_BIN)/LLgen LLGENOPTIONS = \ - -v + -n SRC_G = $(SRC_DIR)/program.g $(SRC_DIR)/declar.g \ $(SRC_DIR)/expression.g $(SRC_DIR)/statement.g @@ -28,7 +28,7 @@ SRC_C = $(SRC_DIR)/LLlex.c $(SRC_DIR)/LLmessage.c $(SRC_DIR)/error.c \ $(SRC_DIR)/desig.c $(SRC_DIR)/code.c $(SRC_DIR)/lookup.c \ $(SRC_DIR)/stab.c GEN_C = tokenfile.c program.c declar.c expression.c statement.c \ - symbol2str.c char.c Lpars.c casestat.c tmpvar.c scope.c next.c + symbol2str.c char.c Lpars.c Lncor.c casestat.c tmpvar.c scope.c next.c CFILES= $(SRC_C) $(GEN_C) SRC_H = $(SRC_DIR)/LLlex.h $(SRC_DIR)/chk_expr.h $(SRC_DIR)/class.h \ @@ -118,6 +118,7 @@ clean: LLfiles: $(GFILES) $(LLGEN) $(LLGENOPTIONS) $(GFILES) @touch LLfiles + @if [ -f Lncor.c ] ; then : ; else touch Lncor.c ; fi hfiles: Parameters $(SRC_DIR)/make.hfiles $(SRC_DIR)/make.hfiles Parameters diff --git a/lang/m2/comp/statement.g b/lang/m2/comp/statement.g index e554b8023..0a60226e1 100644 --- a/lang/m2/comp/statement.g +++ b/lang/m2/comp/statement.g @@ -43,7 +43,8 @@ statement(register t_node **pnd;) ActualParameters(&(nd->nd_RIGHT))? | [ BECOMES - | '=' { error("':=' expected instead of '='"); + | %erroneous '=' + { error("':=' expected instead of '='"); DOT = BECOMES; } ]