]> git.saurik.com Git - bison.git/blobdiff - data/yacc.c
(libbison_a_SOURCES): Remove readpipe.c.
[bison.git] / data / yacc.c
index b2d4cc538c7d6ccd79fa7943a433ffa466ec7e51..35e8da4f5cdcf05089b7459bd8cf4e20918e34e5 100644 (file)
@@ -130,6 +130,11 @@ m4_divert(0)dnl
 b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
              [1984, 1989, 1990, 2000, 2001, 2002])
 
+/* As a special exception, when this file is copied by Bison into a
+   Bison output file, you may use that output file without restriction.
+   This special exception was added by the Free Software Foundation
+   in version 1.24 of Bison.  */
+
 /* Written by Richard Stallman by simplifying the original so called
    ``semantic'' parser.  */
 
@@ -161,11 +166,11 @@ m4_if(b4_prefix[], [yy], [],
 #define yynerrs b4_prefix[]nerrs
 b4_location_if([#define yylloc b4_prefix[]lloc])])
 
+b4_token_defines(b4_tokens)
+
 /* Copy the first part of user declarations.  */
 b4_pre_prologue
 
-b4_token_defines(b4_tokens)
-
 /* Enabling traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG b4_debug
@@ -302,6 +307,12 @@ b4_location_if(
 
 #endif
 
+#if defined (__STDC__) || defined (__cplusplus)
+   typedef signed char yysigned_char;
+#else
+   typedef short yysigned_char;
+#endif
+
 /* YYFINAL -- State number of the termination state. */
 #define YYFINAL  b4_final_state_number
 #define YYLAST   b4_last
@@ -323,7 +334,7 @@ b4_location_if(
   ((unsigned)(X) <= YYMAXUTOK ? yytranslate[[X]] : YYUNDEFTOK)
 
 /* YYTRANSLATE[[YYLEX]] -- Bison symbol number corresponding to YYLEX.  */
-static const b4_uint_type(b4_translate_max) yytranslate[[]] =
+static const b4_int_type_for([b4_translate]) yytranslate[[]] =
 {
   b4_translate
 };
@@ -331,19 +342,19 @@ static const b4_uint_type(b4_translate_max) yytranslate[[]] =
 #if YYDEBUG
 /* YYPRHS[[YYN]] -- Index of the first RHS symbol of rule number YYN in
    YYRHS.  */
-static const b4_uint_type(b4_prhs_max) yyprhs[[]] =
+static const b4_int_type_for([b4_prhs]) yyprhs[[]] =
 {
   b4_prhs
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const b4_sint_type(b4_rhs_max) yyrhs[[]] =
+static const b4_int_type_for([b4_rhs]) yyrhs[[]] =
 {
   b4_rhs
 };
 
 /* YYRLINE[[YYN]] -- source line where rule number YYN was defined.  */
-static const b4_uint_type(b4_rline_max) yyrline[[]] =
+static const b4_int_type_for([b4_rline]) yyrline[[]] =
 {
   b4_rline
 };
@@ -358,21 +369,23 @@ static const char *const yytname[[]] =
 };
 #endif
 
+# ifdef YYPRINT
 /* YYTOKNUM[[YYLEX-NUM]] -- Internal token number corresponding to
    token YYLEX-NUM.  */
-static const short yytoknum[[]] =
+static const b4_int_type_for([b4_toknum]) yytoknum[[]] =
 {
   b4_toknum
 };
+# endif
 
 /* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives.  */
-static const b4_uint_type(b4_r1_max) yyr1[[]] =
+static const b4_int_type_for([b4_r1]) yyr1[[]] =
 {
   b4_r1
 };
 
 /* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN.  */
-static const b4_uint_type(b4_r2_max) yyr2[[]] =
+static const b4_int_type_for([b4_r2]) yyr2[[]] =
 {
   b4_r2
 };
@@ -380,13 +393,13 @@ static const b4_uint_type(b4_r2_max) yyr2[[]] =
 /* YYDEFACT[[STATE-NAME]] -- Default rule to reduce with in state
    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
    means the default is an error.  */
-static const short yydefact[[]] =
+static const b4_int_type_for([b4_defact]) yydefact[[]] =
 {
   b4_defact
 };
 
 /* YYDEFGOTO[[NTERM-NUM]]. */
-static const short yydefgoto[[]] =
+static const b4_int_type_for([b4_defgoto]) yydefgoto[[]] =
 {
   b4_defgoto
 };
@@ -394,34 +407,35 @@ static const short yydefgoto[[]] =
 /* YYPACT[[STATE-NUM]] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
 #define YYPACT_NINF b4_pact_ninf
-static const b4_sint_type(b4_pact_max) yypact[[]] =
+static const b4_int_type_for([b4_pact]) yypact[[]] =
 {
   b4_pact
 };
 
 /* YYPGOTO[[NTERM-NUM]].  */
-static const short yypgoto[[]] =
+static const b4_int_type_for([b4_pgoto]) yypgoto[[]] =
 {
   b4_pgoto
 };
 
 /* YYTABLE[[YYPACT[STATE-NUM]]].  What to do in state STATE-NUM.  If
    positive, shift that token.  If negative, reduce the rule which
-   number is the opposite.  If zero, do what YYDEFACT says.  */
+   number is the opposite.  If zero, do what YYDEFACT says.
+   If YYTABLE_NINF, parse error.  */
 #define YYTABLE_NINF b4_table_ninf
-static const b4_sint_type(b4_table_max) yytable[[]] =
+static const b4_int_type_for([b4_table]) yytable[[]] =
 {
   b4_table
 };
 
-static const short yycheck[[]] =
+static const b4_int_type_for([b4_check]) yycheck[[]] =
 {
   b4_check
 };
 
 /* YYSTOS[[STATE-NUM]] -- The (internal number of the) accessing
    symbol of state STATE-NUM.  */
-static const b4_uint_type(b4_stos_max) yystos[[]] =
+static const b4_int_type_for([b4_stos]) yystos[[]] =
 {
   b4_stos
 };
@@ -492,13 +506,14 @@ while (0)
 
 /* YYLEX -- calling `yylex' with the right arguments.  */
 
-b4_pure_if(
-[#ifdef YYLEX_PARAM
-# define YYLEX yylex (&yylval[]b4_location_if([, &yylloc]), YYLEX_PARAM)
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (b4_pure_if([&yylval[]b4_location_if([, &yylloc]), ])YYLEX_PARAM)
 #else
-# define YYLEX yylex (&yylval[]b4_location_if([, &yylloc]))
-#endif],
-[#define YYLEX yylex ()])
+# define YYLEX b4_c_function_call([yylex], [int],
+                   b4_pure_if([[[[]], [[&yylval]]],
+                               b4_location_if([[[], [&yylloc]],])])
+                   m4_fst(b4_lex_param))
+#endif
 
 /* Enable debugging if requested.  */
 #if YYDEBUG
@@ -603,6 +618,69 @@ yystpcpy (yydest, yysrc)
 
 \f
 
+#if YYDEBUG
+/*-----------------------------.
+| Print this symbol on YYOUT.  |
+`-----------------------------*/
+
+b4_c_function([yysymprint],
+             [static void],
+             [[FILE*],   [yyout]],
+             [[int],     [yytype]],
+             [[YYSTYPE], [yyvalue]]b4_location_if([,
+             [[YYLTYPE], [yylocation]]]))
+{
+  /* Pacify ``unused variable'' warnings.  */
+  (void) yyvalue;
+b4_location_if([  (void) yylocation;
+])dnl
+
+  if (yytype < YYNTOKENS)
+    {
+      YYFPRINTF (yyout, "token %s (", yytname[[yytype]]);
+# ifdef YYPRINT
+      YYPRINT (yyout, yytoknum[[yytype]], yyvalue);
+# endif
+    }
+  else
+    YYFPRINTF (yyout, "nterm %s (", yytname[[yytype]]);
+
+  switch (yytype)
+    {
+m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
+      default:
+        break;
+    }
+  YYFPRINTF (yyout, ")");
+}
+#endif /* YYDEBUG. */
+
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol.  |
+`-----------------------------------------------*/
+
+b4_c_function([yydestruct],
+             [static void],
+             [[int],     [yytype]],
+             [[YYSTYPE], [yyvalue]]b4_location_if([,
+             [[YYLTYPE], [yylocation]]]))
+{
+  /* Pacify ``unused variable'' warnings.  */
+  (void) yyvalue;
+b4_location_if([  (void) yylocation;
+])dnl
+
+  switch (yytype)
+    {
+m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))dnl
+      default:
+        break;
+    }
+}
+
+\f
+
 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
    into yyparse.  The argument should have type void *.
    It should actually point to an object.
@@ -631,15 +709,6 @@ int yyparse (void);
 # endif
 #endif
 
-#if defined (__STDC__) || defined (__cplusplus)
-static void yydestruct (int yytype,
-                       YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]));
-# if YYDEBUG
-static void yysymprint (FILE* out, int yytype,
-                       YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]));
-# endif
-#endif
-
 m4_divert_push([KILL])# ======================== M4 code.
 # b4_declare_parser_variables
 # ---------------------------
@@ -856,28 +925,19 @@ yybackup:
       YYDPRINTF ((stderr, "\n"));
     }
 
+  /* If the proper action on seeing token YYCHAR1 is to reduce or to
+     detect an error, take that action.  */
   yyn += yychar1;
   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yychar1)
     goto yydefault;
-
   yyn = yytable[yyn];
-
-  /* yyn is what to do for this token type in this state.
-     Negative => reduce, -yyn is rule number.
-     Positive => shift, yyn is new state.
-       New state is final state => don't bother to shift,
-       just return success.
-     0, or most negative number => error.  */
-
-  if (yyn < 0)
+  if (yyn <= 0)
     {
-      if (yyn == YYTABLE_NINF)
+      if (yyn == 0 || yyn == YYTABLE_NINF)
        goto yyerrlab;
       yyn = -yyn;
       goto yyreduce;
     }
-  else if (yyn == 0)
-    goto yyerrlab;
 
   if (yyn == YYFINAL)
     YYACCEPT;
@@ -922,8 +982,8 @@ yyreduce:
   /* If YYLEN is nonzero, implement the default value of the action:
      `$$ = $1'.
 
-     Otherwise, the following line sets YYVAL to the semantic value of
-     the lookahead token.  This behavior is undocumented and Bison
+     Otherwise, the following line sets YYVAL to garbage.
+     This behavior is undocumented and Bison
      users should not rely upon it.  Assigning to YYVAL
      unconditionally makes the parser a bit smaller, and it avoids a
      GCC warning that YYVAL may be used uninitialized.  */
@@ -998,13 +1058,13 @@ yyerrlab:
   if (!yyerrstatus)
     {
       ++yynerrs;
-
 #if YYERROR_VERBOSE
       yyn = yypact[yystate];
 
       if (YYPACT_NINF < yyn && yyn < YYLAST)
        {
          YYSIZE_T yysize = 0;
+         int yytype = YYTRANSLATE (yychar);
          char *yymsg;
          int yyx, yycount;
 
@@ -1013,15 +1073,15 @@ yyerrlab:
             YYCHECK.  */
          for (yyx = yyn < 0 ? -yyn : 0;
               yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
-           if (yycheck[yyx + yyn] == yyx)
+           if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
              yysize += yystrlen (yytname[yyx]) + 15, yycount++;
          yysize += yystrlen ("parse error, unexpected ") + 1;
-         yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
+         yysize += yystrlen (yytname[yytype]);
          yymsg = (char *) YYSTACK_ALLOC (yysize);
          if (yymsg != 0)
            {
              char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
-             yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
+             yyp = yystpcpy (yyp, yytname[yytype]);
 
              if (yycount < 5)
                {
@@ -1029,7 +1089,7 @@ yyerrlab:
                  for (yyx = yyn < 0 ? -yyn : 0;
                       yyx < (int) (sizeof (yytname) / sizeof (char *));
                       yyx++)
-                   if (yycheck[yyx + yyn] == yyx)
+                   if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
                      {
                        const char *yyq = ! yycount ? ", expecting " : " or ";
                        yyp = yystpcpy (yyp, yyq);
@@ -1039,13 +1099,13 @@ yyerrlab:
                }
              yyerror (yymsg);
              YYSTACK_FREE (yymsg);
-           }
-         else
-           yyerror ("parse error; also virtual memory exhausted");
-        }
+           }
+         else
+           yyerror ("parse error; also virtual memory exhausted");
+       }
       else
 #endif /* YYERROR_VERBOSE */
-        yyerror ("parse error");
+       yyerror ("parse error");
     }
   goto yyerrlab1;
 
@@ -1174,67 +1234,16 @@ yyreturn:
 ]}
 
 
-/*-----------------------------------------------.
-| Release the memory associated to this symbol.  |
-`-----------------------------------------------*/
-
-static void
-yydestruct (int yytype,
-           YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
-{
-  /* Pacify ``unused variable'' warnings.  */
-  (void) yyvalue;
-b4_location_if([  (void) yylocation;
-])dnl
-
-  switch (yytype)
-    {
-m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))dnl
-      default:
-        break;
-    }
-}
-
-
-#if YYDEBUG
-/*-----------------------------.
-| Print this symbol on YYOUT.  |
-`-----------------------------*/
-
-static void
-yysymprint (FILE* yyout, int yytype,
-           YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
-{
-  /* Pacify ``unused variable'' warnings.  */
-  (void) yyvalue;
-b4_location_if([  (void) yylocation;
-])dnl
-
-  if (yytype < YYNTOKENS)
-    {
-      YYFPRINTF (yyout, "token %s (", yytname[[yytype]]);
-# ifdef YYPRINT
-      YYPRINT (yyout, yytoknum[[yytype]], yyvalue);
-# endif
-    }
-  else
-    YYFPRINTF (yyout, "nterm %s (", yytname[[yytype]]);
-
-  switch (yytype)
-    {
-m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
-      default:
-        break;
-    }
-  YYFPRINTF (yyout, ")");
-}
-#endif /* YYDEBUG. */
-
 b4_epilogue
 m4_if(b4_defines_flag, 0, [],
 [#output "b4_output_header_name"
 b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
-              [1984, 1989, 1990, 2000, 2001, 2002])
+             [1984, 1989, 1990, 2000, 2001, 2002])
+
+/* As a special exception, when this file is copied by Bison into a
+   Bison output file, you may use that output file without restriction.
+   This special exception was added by the Free Software Foundation
+   in version 1.24 of Bison.  */
 
 #ifndef b4_header_guard
 # define b4_header_guard