]> git.saurik.com Git - bison.git/blobdiff - src/reader.c
* src/bison.simple: Remove #line just before %%epilogue. It
[bison.git] / src / reader.c
index d3c089510774a80359b2ac144e3cea9c3f564407..d42d90ecc9492b62c7f99761eef379c190feae57 100644 (file)
@@ -437,14 +437,12 @@ copy_definition (void)
   /* -1 while reading a character if prev char was %. */
   int after_percent;
 
-#if 0
   if (!no_lines_flag)
     {
       obstack_fgrow2 (&attrs_obstack, muscle_find ("linef"),
                      lineno, quotearg_style (c_quoting_style,
                                              muscle_find("filename")));
     }
-#endif
 
   after_percent = 0;
 
@@ -964,14 +962,60 @@ parse_muscle_decl (void)
 }
 
 
+
+/*---------------------------------.
+| Parse a double quoted parameter. |
+`---------------------------------*/
+
+static const char *
+parse_dquoted_param (const char *from)
+{
+  struct obstack param_obstack;
+  const char *param = NULL;
+  int c;
+
+  obstack_init (&param_obstack);
+  c = skip_white_space ();
+
+  if (c != '"')
+    {
+      complain (_("invalid %s declaration"), from);
+      ungetc (c, finput);
+      skip_to_char ('%');
+      return NULL;
+    }
+
+  for (;;)
+    {
+      if (literalchar (NULL, &c, '\"'))
+       obstack_1grow (&param_obstack, c);
+      else
+       break;
+    }
+
+  obstack_1grow (&param_obstack, '\0');
+  param = obstack_finish (&param_obstack);
+
+  if (c != '"' || strlen (param) == 0)
+    {
+      complain (_("invalid %s declaration"), from);
+      if (c != '"')
+       ungetc (c, finput);
+      skip_to_char ('%');
+      return NULL;
+    }
+
+  return param;
+}
+
 /*----------------------------------.
 | Parse what comes after %skeleton. |
 `----------------------------------*/
 
-void
+static void
 parse_skel_decl (void)
 {
-  /* Complete with parse_dquoted_param () on the CVS branch 1.29.  */
+  skeleton = parse_dquoted_param ("%skeleton");
 }
 
 /*----------------------------------------------------------------.
@@ -1054,10 +1098,10 @@ read_declarations (void)
            case tok_stropt:
            case tok_intopt:
            case tok_obsolete:
-           case tok_illegal:
              abort ();
              break;
 
+           case tok_illegal:
            default:
              complain (_("unrecognized: %s"), token_buffer);
              skip_to_char ('%');
@@ -1087,7 +1131,6 @@ copy_action (symbol_list *rule, int stack_offset)
 {
   int c;
   int count;
-  char buf[4096];
 
   /* offset is always 0 if parser has already popped the stack pointer */
   if (semantic_parser)
@@ -1474,12 +1517,14 @@ readgram (void)
                  /* Make a dummy nonterminal, a gensym.  */
                  bucket *sdummy = gensym ();
 
-                 /* Make a new rule, whose body is empty,
-                    before the current one, so that the action
-                    just read can belong to it.  */
+                 /* Make a new rule, whose body is empty, before the
+                    current one, so that the action just read can
+                    belong to it.  */
                  nrules++;
                  nitems++;
                  p = symbol_list_new (sdummy);
+                 /* Attach its lineno to that of the host rule. */
+                 p->line = crule->line;
                  if (crule1)
                    crule1->next = p;
                  else
@@ -1643,6 +1688,13 @@ read_additionnal_code (void)
 
   obstack_init (&el_obstack);
 
+  if (!no_lines_flag)
+    {
+      obstack_fgrow2 (&el_obstack, muscle_find ("linef"),
+                     lineno, quotearg_style (c_quoting_style,
+                                             muscle_find("filename")));
+    }
+
   while ((c = getc (finput)) != EOF)
     obstack_1grow (&el_obstack, c);
 
@@ -1857,25 +1909,13 @@ symbols_output (void)
     obstack_free (&tokendefs, NULL);
   }
 
-#if 0
-  if (!no_parser_flag)
-    output_token_defines (&table_obstack);
-#endif
-
   if (defines_flag)
     {
       output_token_defines (&defines_obstack);
 
       if (!pure_parser)
-       {
-         if (spec_name_prefix)
-           obstack_fgrow1 (&defines_obstack, "\nextern YYSTYPE %slval;\n",
-                           spec_name_prefix);
-         else
-           obstack_sgrow (&defines_obstack,
-                                "\nextern YYSTYPE yylval;\n");
-       }
-
+       obstack_fgrow1 (&defines_obstack, "\nextern YYSTYPE %slval;\n",
+                       spec_name_prefix);
       if (semantic_parser)
        {
          int i;
@@ -1923,6 +1963,7 @@ packgram (void)
       rule_table[ruleno].lhs = p->sym->value;
       rule_table[ruleno].rhs = itemno;
       rule_table[ruleno].line = p->line;
+      rule_table[ruleno].useful = TRUE;
 
       p = p->next;
       while (p && p->sym)
@@ -1956,6 +1997,9 @@ packgram (void)
     }
 
   ritem[itemno] = 0;
+
+  if (trace_flag)
+    ritem_print (stderr);
 }
 \f
 /*-------------------------------------------------------------------.
@@ -2022,7 +2066,6 @@ reader (void)
   /* Assign the symbols their symbol numbers.  Write #defines for the
      token symbols into FDEFINES if requested.  */
   packsymbols ();
-  symbols_output ();
   /* Convert the grammar into the format described in gram.h.  */
   packgram ();
   /* Output the headers. */