Explorar o código

Fix: error recovery sometimes skipped tokens it needed later on

ceriel %!s(int64=30) %!d(string=hai) anos
pai
achega
656fb00e9b
Modificáronse 2 ficheiros con 30 adicións e 1 borrados
  1. 3 1
      util/LLgen/lib/incl
  2. 27 0
      util/LLgen/lib/rec

+ 3 - 1
util/LLgen/lib/incl

@@ -10,7 +10,7 @@
 extern int LLsymb;
 
 #define LL_SAFE(x)	/* Nothing */
-#define LL_SSCANDONE(x)	if (LLsymb != x) LLerror(x); else
+#define LL_SSCANDONE(x)	if (LLsymb != x) LLsafeerror(x); else
 #define LL_SCANDONE(x)	if (LLsymb != x) LLerror(x); else
 #define LL_NOSCANDONE(x) LLscan(x)
 #ifdef LL_FASTER
@@ -32,6 +32,7 @@ extern void LLread(void);
 extern int LLskip(void);
 extern int LLnext(int);
 extern void LLerror(int);
+extern void LLsafeerror(int);
 extern void LLnewlevel(unsigned int *);
 extern void LLoldlevel(unsigned int *);
 #ifndef LL_FASTER
@@ -45,6 +46,7 @@ extern LLread();
 extern int LLskip();
 extern int LLnext();
 extern LLerror();
+extern LLsafeerror();
 extern LLnewlevel();
 extern LLoldlevel();
 #ifndef LL_FASTER

+ 27 - 0
util/LLgen/lib/rec

@@ -97,6 +97,33 @@ LLerror(t)
 	if (LLsymb != t) LLmessage(t);
 }
 
+#if LL_ANSI_C
+void LLsafeerror(int t)
+#else
+LLsafeerror(t)
+	int	t;
+#endif
+{
+	register int i;
+
+	if (t == EOFILE && LLsymb <= 0) return;
+#ifdef LL_NEWMESS
+	if (t == EOFILE) {
+#ifdef LL_USERHOOK
+		static int lst[] = { EOFILE, 0 };
+		if (LLuserhook(EOFILE, lst)) /* nothing */;
+#endif /* LL_USERHOOK */
+		if (LLsymb != EOFILE && LLsymb > 0) {
+			LLmessage(-1);
+			while ((LLsymb = LL_LEXI()) > 0 && LLsymb != EOFILE) 
+				/* nothing */ ;
+		}
+		return;
+	}
+#endif
+	LLmessage(t);
+}
+
 #ifndef LLNOFIRSTS
 #if LL_ANSI_C
 int LLfirst(int x, int d) {