bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error recovery


From: Akim Demaille
Subject: Error recovery
Date: 09 Jul 2002 16:45:58 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * src/parse-gram.y (rules_or_grammar_declaration): Add an error
        recovery rule, and forbid extensions when --yacc.
        (gram_error): Use complain_at.
        * src/reader.c (reader): Exit if there were parse errors.

Index: src/parse-gram.y
===================================================================
RCS file: /cvsroot/bison/bison/src/parse-gram.y,v
retrieving revision 1.17
diff -u -u -r1.17 parse-gram.y
--- src/parse-gram.y 30 Jun 2002 17:27:57 -0000 1.17
+++ src/parse-gram.y 9 Jul 2002 13:10:31 -0000
@@ -30,6 +30,7 @@

 %{
 #include "system.h"
+#include "complain.h"
 #include "muscle_tab.h"
 #include "files.h"
 #include "getargs.h"
@@ -338,6 +339,14 @@
 rules_or_grammar_declaration:
   rules
 | grammar_declaration ";"
+    {
+      if (yacc_flag)
+       complain_at (@$, _("POSIX forbids declarations in the grammar"));
+    }
+| error ";"
+    {
+      yyerrok;
+    }
 ;

 rules:
@@ -453,6 +462,5 @@
 gram_error (gram_control_t *control ATTRIBUTE_UNUSED,
            location_t *yylloc, const char *msg)
 {
-  LOCATION_PRINT (stderr, *yylloc);
-  fprintf (stderr, ": %s\n", msg);
+  complain_at (*yylloc, "%s", msg);
 }
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.203
diff -u -u -r1.203 reader.c
--- src/reader.c 30 Jun 2002 17:31:19 -0000 1.203
+++ src/reader.c 9 Jul 2002 13:10:42 -0000
@@ -502,6 +502,11 @@
   scanner_initialize ();
   gram_parse (&gram_control);

+  /* If something went wrong during the parsing, don't try to
+     continue.  */
+  if (complain_message_count)
+    exit (1);
+
   /* Grammar has been read.  Do some checking */
   if (nrules == 0)
     fatal (_("no rules in the input grammar"));



reply via email to

[Prev in Thread] Current Thread [Next in Thread]