]> git.saurik.com Git - bison.git/blobdiff - src/reader.c
i18n: fix untranslatable string.
[bison.git] / src / reader.c
index 4ac5977dea2f4fb5c4137f7978ea31b61e76e032..03c5bae5cc74c5221f8878b3e9a528e2e3360d7f 100644 (file)
@@ -1,7 +1,7 @@
 /* Input parser for Bison
 
-   Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000, 2001, 2002, 2003,
-   2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000-2003, 2005-2007,
+   2009-2010 Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -29,7 +29,7 @@
 #include "files.h"
 #include "getargs.h"
 #include "gram.h"
-#include "muscle_tab.h"
+#include "muscle-tab.h"
 #include "reader.h"
 #include "symlist.h"
 #include "symtab.h"
@@ -320,6 +320,15 @@ grammar_rule_check (const symbol_list *r)
            warn_at (r->location, _("unset value: $$"));
        }
   }
+
+  /* See comments in grammar_current_rule_prec_set for how POSIX
+     mandates this complaint.  It's only for identifiers, so skip
+     it for char literals and strings, which are always tokens.  */
+  if (r->ruleprec
+      && r->ruleprec->tag[0] != '\'' && r->ruleprec->tag[0] != '"'
+      && !r->ruleprec->declared && !r->ruleprec->prec)
+    complain_at (r->location, _("token for %%prec is not defined: %s"),
+                 r->ruleprec->tag);
 }
 
 
@@ -396,6 +405,16 @@ grammar_midrule_action (void)
 void
 grammar_current_rule_prec_set (symbol *precsym, location loc)
 {
+  /* POSIX says that any identifier is a nonterminal if it does not
+     appear on the LHS of a grammar rule and is not defined by %token
+     or by one of the directives that assigns precedence to a token.  We
+     ignore this here because the only kind of identifier that POSIX
+     allows to follow a %prec is a token and because assuming it's a
+     token now can produce more logical error messages.  Nevertheless,
+     grammar_rule_check does obey what we believe is the real intent of
+     POSIX here: that an error be reported for any identifier that
+     appears after %prec but that is not defined separately as a
+     token.  */
   symbol_class_set (precsym, token_sym, loc, false);
   if (current_rule->ruleprec)
     complain_at (loc, _("only one %s allowed per rule"), "%prec");
@@ -608,9 +627,9 @@ prepare_percent_define_front_end_variables (void)
     char *lr_type;
     /* IELR would be a better default, but LALR is historically the
        default.  */
-    muscle_percent_define_default ("lr.type", "LALR");
+    muscle_percent_define_default ("lr.type", "lalr");
     lr_type = muscle_percent_define_get ("lr.type");
-    if (0 != strcmp (lr_type, "canonical LR"))
+    if (0 != strcmp (lr_type, "canonical-lr"))
       muscle_percent_define_default ("lr.default-reductions", "all");
     else
       muscle_percent_define_default ("lr.default-reductions", "accepting");
@@ -620,7 +639,7 @@ prepare_percent_define_front_end_variables (void)
   /* Check %define front-end variables.  */
   {
     static char const * const values[] = {
-      "lr.type", "LALR", "IELR", "canonical LR", NULL,
+      "lr.type", "lalr", "ielr", "canonical-lr", NULL,
       "lr.default-reductions", "all", "consistent", "accepting", NULL,
       NULL
     };