bison-patches
[Top][All Lists]
Advanced

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

01-empty-language.patch


From: Akim Demaille
Subject: 01-empty-language.patch
Date: Tue, 30 Jul 2002 14:14:48 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        
        * src/reduce.c (reduce_grammar): When the language is empty,
        complain about the start symbol, not the axiom.
        Use its location.
        * tests/reduce.at (Empty Language): New.
        
Index: src/reduce.c
--- src/reduce.c Thu, 25 Jul 2002 23:18:58 +0200 akim
+++ src/reduce.c Sun, 28 Jul 2002 13:51:51 +0200 akim
@@ -439,8 +439,9 @@
   reduce_print ();
 
   if (!bitset_test (N, axiom->number - ntokens))
-    fatal (_("Start symbol %s does not derive any sentence"),
-          symbols[axiom->number]->tag);
+    fatal_at (startsymbol_location,
+             _("start symbol %s does not derive any sentence"),
+             startsymbol->tag);
 
   /* First reduce the nonterminals, as they renumber themselves in the
      whole grammar.  If you change the order, nonterms would be
Index: tests/reduce.at
--- tests/reduce.at Sat, 15 Jun 2002 16:53:23 +0200 akim
+++ tests/reduce.at Sun, 28 Jul 2002 13:56:57 +0200 akim
@@ -332,3 +332,24 @@ input.y:7.12-24: warning: useless rule: 
 ]])
 
 AT_CLEANUP
+
+
+
+## ---------------- ##
+## Empty Language.  ##
+## ---------------- ##
+
+AT_SETUP([Empty Language])
+
+AT_DATA([[input.y]],
+[[%output="input.c"
+%%
+exp: exp;
+]])
+
+AT_CHECK([[bison input.y]], 1, [],
+[[input.y: warning: 2 useless nonterminals and 2 useless rules
+input.y:3.1-3: fatal error: start symbol exp does not derive any sentence
+]])
+
+AT_CLEANUP



reply via email to

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