X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/992e874a7c2c243e4b83752235a26ccdb9b1ef0a..4b7a4c1b1c8c18e9ad2517c117442b9b7d7e671a:/src/reader.c

diff --git a/src/reader.c b/src/reader.c
index 1b2dcfce..043fea8b 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -36,6 +36,7 @@
 #include "scan-gram.h"
 #include "scan-code.h"
 
+static void prepare_percent_define_front_end_variables (void);
 static void check_and_convert_grammar (void);
 
 static symbol_list *grammar = NULL;
@@ -590,36 +591,41 @@ reader (void)
   gram_debug = trace_flag & trace_parse;
   gram_scanner_initialize ();
   gram_parse ();
+  prepare_percent_define_front_end_variables ();
 
-  /* Set front-end %define variable defaults.  */
+  if (! complaint_issued)
+    check_and_convert_grammar ();
+
+  xfclose (gram_in);
+}
+
+static void
+prepare_percent_define_front_end_variables (void)
+{
+  /* Set %define front-end variable defaults.  */
   muscle_percent_define_default ("lr.keep-unreachable-states", "false");
   {
     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");
     free (lr_type);
   }
 
-  /* Check front-end %define variables.  */
+  /* 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
     };
     muscle_percent_define_check_values (values);
   }
-
-  if (! complaint_issued)
-    check_and_convert_grammar ();
-
-  xfclose (gram_in);
 }
 
 
@@ -635,9 +641,6 @@ check_and_convert_grammar (void)
   if (nrules == 0)
     fatal (_("no rules in the input grammar"));
 
-  /* Report any undefined symbols and consider them nonterminals.  */
-  symbols_check_defined ();
-
   /* If the user did not define her ENDTOKEN, do it now. */
   if (!endtoken)
     {
@@ -648,6 +651,9 @@ check_and_convert_grammar (void)
       endtoken->user_token_number = 0;
     }
 
+  /* Report any undefined symbols and consider them nonterminals.  */
+  symbols_check_defined ();
+
   /* Find the start symbol if no %start.  */
   if (!start_flag)
     {