]> git.saurik.com Git - bison.git/blobdiff - data/bison.simple
As a result of the previous patch, it is no longer needed
[bison.git] / data / bison.simple
index f4af302c18267c531317ee175c7dd9871c56b859..84e77ec9d5cdc04c70d127eb824f7addb793f05f 100644 (file)
@@ -1,11 +1,46 @@
-%%{section} %%{output-prefix} %%{output-infix} %%".c"
-/* -*- C -*- */
+m4_divert(-1)
 
-/* A Bison parser, made from %%{filename}
-   by GNU bison %%{version}.  */
+m4_define_default([b4_input_suffix], [.y])
 
-/* Skeleton output parser for bison,
+m4_define_default([b4_output_parser_suffix],
+[m4_translit(b4_input_suffix, [yY], [cC])])
 
+m4_define_default([b4_output_parser_name],
+[b4_output_prefix[]b4_output_infix[]b4_output_parser_suffix[]])
+
+
+m4_define_default([b4_output_header_suffix],
+[m4_translit(b4_input_suffix, [yY], [hH])])
+
+m4_define_default([b4_output_header_name],
+[b4_output_prefix[]b4_output_infix[]b4_output_header_suffix[]])
+
+m4_define_default([b4_header_guard],
+                  [m4_bpatsubst(m4_toupper([BISON_]b4_output_header_name),
+                                [[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]], [_])])
+
+
+# b4_token_defines(TOKEN-NAME, TOKEN-NUMBER)
+# ------------------------------------------
+# Output the definition of this token as #define.
+m4_define([b4_token_define],
+[#define $1 $2
+])
+
+
+# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
+# -------------------------------------------------------
+# Output the definition of the tokens as #define.
+m4_define([b4_token_defines],
+[m4_map([b4_token_define], [$@])])
+
+
+m4_divert(0)dnl
+#output "b4_output_parser_name"
+/* A Bison parser, made from b4_filename
+   by GNU bison b4_version.  */
+
+/* Skeleton output parser for Bison,
    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
    Foundation, Inc.
 
 #define YYBISON        1
 
 /* Pure parsers.  */
-#define YYPURE %%{pure}
+#define YYPURE b4_pure
 
 /* Using locations.  */
-#define YYLSP_NEEDED %%{locations-flag}
+#define YYLSP_NEEDED b4_locations_flag
 
-/* If NAME_PREFIX is specified substitute the variables and functions
+m4_if(b4_prefix[], [yy], [],
+[/* If NAME_PREFIX is specified substitute the variables and functions
    names.  */
-#define yyparse %%{prefix}parse
-#define yylex   %%{prefix}lex
-#define yyerror %%{prefix}error
-#define yylval  %%{prefix}lval
-#define yychar  %%{prefix}char
-#define yydebug %%{prefix}debug
-#define yynerrs %%{prefix}nerrs
+#define yyparse b4_prefix[]parse
+#define yylex   b4_prefix[]lex
+#define yyerror b4_prefix[]error
+#define yylval  b4_prefix[]lval
+#define yychar  b4_prefix[]char
+#define yydebug b4_prefix[]debug
+#define yynerrs b4_prefix[]nerrs
 #if YYLSP_NEEDED
-# define yylloc %%{prefix}lloc
+# define yylloc b4_prefix[]lloc
 #endif
-
+])
 
 /* Copy the user declarations.  */
-%%{prologue}
+b4_prologue
 
 /* Enabling traces.  */
 #ifndef YYDEBUG
-# define YYDEBUG %%{debug}
+# define YYDEBUG b4_debug
 #endif
 
 /* Enabling verbose error messages.  */
 # undef YYERROR_VERBOSE
 # define YYERROR_VERBOSE 1
 #else
-# define YYERROR_VERBOSE %%{error-verbose}
+# define YYERROR_VERBOSE b4_error_verbose
 #endif
 
 #ifndef YYSTYPE
-typedef %%{stype} yystype;
+m4_ifdef([b4_stype_line],
+[#line b4_stype_line "b4_filename"
+])dnl
+typedef b4_stype yystype;
 # define YYSTYPE yystype
 #endif
 
@@ -86,11 +125,11 @@ typedef struct yyltype
   int last_line;
   int last_column;
 } yyltype;
-# define YYLTYPE %%{ltype}
+# define YYLTYPE b4_ltype
 #endif
 
-/* Line %%{skeleton-line} of %%{skeleton}.  */
-#line %%{line} "%%{parser-file-name}"
+/* Line __line__ of __file__.  */
+#line __oline__
 
 /* All symbols defined below should begin with yy or YY, to avoid
    infringing on user name space.  This should be done even for local
@@ -99,12 +138,6 @@ typedef struct yyltype
    define necessary library symbols; they are noted "INFRINGES ON
    USER NAME SPACE" below.  */
 
-#ifdef __cplusplus
-# define YYSTD(x) std::x
-#else
-# define YYSTD(x) x
-#endif
-
 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
 
 /* The parser invokes alloca or malloc; define the necessary symbols.  */
@@ -127,17 +160,12 @@ typedef struct yyltype
    /* Pacify GCC's `empty if-body' warning. */
 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
 # else
-#  ifdef __cplusplus
-#   include <cstdlib> /* INFRINGES ON USER NAME SPACE */
-#   define YYSIZE_T std::size_t
-#  else
-#   ifdef __STDC__
-#    include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-#    define YYSIZE_T size_t
-#   endif
+#  if defined (__STDC__) || defined (__cplusplus)
+#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+#   define YYSIZE_T size_t
 #  endif
-#  define YYSTACK_ALLOC YYSTD (malloc)
-#  define YYSTACK_FREE YYSTD (free)
+#  define YYSTACK_ALLOC malloc
+#  define YYSTACK_FREE free
 # endif
 
 /* A type that is properly aligned for any stack member.  */
@@ -165,19 +193,36 @@ union yyalloc
      + YYSTACK_GAP_MAX)
 # endif
 
-/* Relocate the TYPE STACK from its old location to the new one.  The
+/* Copy COUNT objects from FROM to TO.  The source and destination do
+   not overlap.  */
+# ifndef YYCOPY
+#  if 1 < __GNUC__
+#   define YYCOPY(To, From, Count) \
+      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+#  else
+#   define YYCOPY(To, From, Count)             \
+      do                                       \
+       {                                       \
+         register YYSIZE_T yyi;                \
+         for (yyi = 0; yyi < (Count); yyi++)   \
+           (To)[yyi] = (From)[yyi];            \
+       }                                       \
+      while (0)
+#  endif
+# endif
+
+/* Relocate STACK from its old location to the new one.  The
    local variables YYSIZE and YYSTACKSIZE give the old and new number of
    elements in the stack, and YYPTR gives the new location of the
    stack.  Advance YYPTR to a properly aligned location for the next
    stack.  */
-# define YYSTACK_RELOCATE(Type, Stack)                                 \
+# define YYSTACK_RELOCATE(Stack)                                       \
     do                                                                 \
       {                                                                        \
        YYSIZE_T yynewbytes;                                            \
-       yymemcpy ((char *) yyptr, (char *) (Stack),                     \
-                 yysize * (YYSIZE_T) sizeof (Type));                   \
+       YYCOPY (&yyptr->Stack, Stack, yysize);                          \
        Stack = &yyptr->Stack;                                          \
-       yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX;     \
+       yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX;   \
        yyptr += yynewbytes / sizeof (*yyptr);                          \
       }                                                                        \
     while (0)
@@ -185,118 +230,118 @@ union yyalloc
 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
 
 /* Tokens.  */
-%%{tokendef}
+b4_token_defines(b4_tokens)
 
 /* YYFINAL -- State number of the termination state. */
-#define YYFINAL  %%{final}
-#define YYFLAG  %%{flag}
-#define YYLAST   %%{last}
+#define YYFINAL  b4_final
+#define YYFLAG  b4_flag
+#define YYLAST   b4_last
 
 /* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS  %%{ntokens}
+#define YYNTOKENS  b4_ntokens
 /* YYNNTS -- Number of nonterminals. */
-#define YYNNTS  %%{nnts}
+#define YYNNTS  b4_nnts
 /* YYNRULES -- Number of rules. */
-#define YYNRULES  %%{nrules}
+#define YYNRULES  b4_nrules
 /* YYNRULES -- Number of states. */
-#define YYNSTATES  %%{nstates}
-#define YYMAXUTOK  %%{maxtok}
+#define YYNSTATES  b4_nstates
+#define YYMAXUTOK  b4_maxtok
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
-#define YYTRANSLATE(x) ((unsigned)(x) <= %%{maxtok} ? yytranslate[x] : %%{nsym})
+#define YYTRANSLATE(x) ((unsigned)(x) <= b4_maxtok ? yytranslate[[x]] : b4_nsym)
 
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
-static const char yytranslate[] =
+/* YYTRANSLATE[[YYLEX]] -- Bison symbol number corresponding to YYLEX.  */
+static const char yytranslate[[]] =
 {
-  %%{translate}
+  b4_translate
 };
 
 #if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+/* YYPRHS[[YYN]] -- Index of the first RHS symbol of rule number YYN in
    YYRHS.  */
-static const short yyprhs[] =
+static const short yyprhs[[]] =
 {
-  %%{prhs}
+  b4_prhs
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const short yyrhs[] =
+static const short yyrhs[[]] =
 {
-  %%{rhs}
+  b4_rhs
 };
 
-/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
-static const short yyrline[] =
+/* YYRLINE[[YYN]] -- source line where rule number YYN was defined.  */
+static const short yyrline[[]] =
 {
-  %%{rline}
+  b4_rline
 };
 #endif
 
 #if (YYDEBUG) || YYERROR_VERBOSE
-/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+/* YYTNME[[SYMBOL-NUM]] -- String name of the symbol SYMBOL-NUM.
    First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
+static const char *const yytname[[]] =
 {
-  %%{tname}
+  b4_tname
 };
 #endif
 
-/* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX.  */
-static const short yytoknum[] =
+/* YYTOKNUM[[YYN]] -- Index in YYTNAME corresponding to YYLEX.  */
+static const short yytoknum[[]] =
 {
-  %%{toknum}
+  b4_toknum
 };
 
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
-static const short yyr1[] =
+/* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives.  */
+static const short yyr1[[]] =
 {
-  %%{r1}
+  b4_r1
 };
 
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
-static const short yyr2[] =
+/* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN.  */
+static const short yyr2[[]] =
 {
-  %%{r2}
+  b4_r2
 };
 
-/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
+/* YYDEFACT[[S]] -- default rule to reduce with in state S when YYTABLE
    doesn't specify something else to do.  Zero means the default is an
    error.  */
-static const short yydefact[] =
+static const short yydefact[[]] =
 {
-  %%{defact}
+  b4_defact
 };
 
-/* YYPGOTO[NTERM-NUM]. */
-static const short yydefgoto[] =
+/* YYPGOTO[[NTERM-NUM]]. */
+static const short yydefgoto[[]] =
 {
-  %%{defgoto}
+  b4_defgoto
 };
 
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+/* YYPACT[[STATE-NUM]] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-static const short yypact[] =
+static const short yypact[[]] =
 {
-  %%{pact}
+  b4_pact
 };
 
-/* YYPGOTO[NTERM-NUM].  */
-static const short yypgoto[] =
+/* YYPGOTO[[NTERM-NUM]].  */
+static const short yypgoto[[]] =
 {
-  %%{pgoto}
+  b4_pgoto
 };
 
-/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
+/* 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.  */
-static const short yytable[] =
+static const short yytable[[]] =
 {
-  %%{table}
+  b4_table
 };
 
-static const short yycheck[] =
+static const short yycheck[[]] =
 {
-  %%{check}
+  b4_check
 };
 
 
@@ -307,14 +352,9 @@ static const short yycheck[] =
 # define YYSIZE_T size_t
 #endif
 #if ! defined (YYSIZE_T)
-# ifdef __cplusplus
-#  include <cstddef> /* INFRINGES ON USER NAME SPACE */
-#  define YYSIZE_T std::size_t
-# else
-#  ifdef __STDC__
-#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-#   define YYSIZE_T size_t
-#  endif
+# if defined (__STDC__) || defined (__cplusplus)
+#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+#  define YYSIZE_T size_t
 # endif
 #endif
 #if ! defined (YYSIZE_T)
@@ -367,8 +407,8 @@ while (0)
 
 #ifndef YYLLOC_DEFAULT
 # define YYLLOC_DEFAULT(Current, Rhs, N)               \
-   Current.last_line   = Rhs[N].last_line;     \
-   Current.last_column = Rhs[N].last_column;
+   Current.last_line   = Rhs[[N]].last_line;   \
+   Current.last_column = Rhs[[N]].last_column;
 #endif
 
 /* YYLEX -- calling `yylex' with the right arguments.  */
@@ -395,12 +435,8 @@ while (0)
 #if YYDEBUG
 
 # ifndef YYFPRINTF
-#  ifdef __cplusplus
-#   include <cstdio>  /* INFRINGES ON USER NAME SPACE */
-#  else
-#   include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-#  endif
-#  define YYFPRINTF YYSTD (fprintf)
+#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+#  define YYFPRINTF fprintf
 # endif
 
 # define YYDPRINTF(Args)                       \
@@ -408,10 +444,8 @@ do {                                               \
   if (yydebug)                                 \
     YYFPRINTF Args;                            \
 } while (0)
-/* Nonzero means print parse trace. [The following comment makes no
-   sense to me.  Could someone clarify it?  --akim] Since this is
-   uninitialized, it does not stop multiple parsers from coexisting.
-   */
+/* Nonzero means print parse trace.  Since this is uninitialized, it
+   does not stop multiple parsers from coexisting.  */
 int yydebug;
 #else /* !YYDEBUG */
 # define YYDPRINTF(Args)
@@ -419,7 +453,7 @@ int yydebug;
 
 /* YYINITDEPTH -- initial size of the parser's stacks.  */
 #ifndef        YYINITDEPTH
-# define YYINITDEPTH %%{initdepth}
+# define YYINITDEPTH b4_initdepth
 #endif
 
 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
@@ -434,38 +468,11 @@ int yydebug;
 #endif
 
 #ifndef YYMAXDEPTH
-# define YYMAXDEPTH %%{maxdepth}
+# define YYMAXDEPTH b4_maxdepth
 #endif
 
 \f
 
-#if ! defined (yyoverflow) && ! defined (yymemcpy)
-# if __GNUC__ > 1              /* GNU C and GNU C++ define this.  */
-#  define yymemcpy __builtin_memcpy
-# else                         /* not GNU C or C++ */
-
-/* This is the most reliable way to avoid incompatibilities
-   in available built-in functions on various systems.  */
-static void
-#  if defined (__STDC__) || defined (__cplusplus)
-yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
-#  else
-yymemcpy (yyto, yyfrom, yycount)
-     char *yyto;
-     const char *yyfrom;
-     YYSIZE_T yycount;
-#  endif
-{
-  register const char *yyf = yyfrom;
-  register char *yyt = yyto;
-  register YYSIZE_T yyi = yycount;
-
-  while (yyi-- != 0)
-    *yyt++ = *yyf++;
-}
-# endif
-#endif
-
 #if YYERROR_VERBOSE
 
 # ifndef yystrlen
@@ -528,13 +535,13 @@ yystpcpy (yydest, yysrc)
    to the proper pointer type.  */
 
 #ifdef YYPARSE_PARAM
-# ifdef __cplusplus
+# if defined (__STDC__) || defined (__cplusplus)
 #  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
 #  define YYPARSE_PARAM_DECL
-# else /* !__cplusplus */
+# else
 #  define YYPARSE_PARAM_ARG YYPARSE_PARAM
 #  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
-# endif /* !__cplusplus */
+# endif
 #else /* !YYPARSE_PARAM */
 # define YYPARSE_PARAM_ARG
 # define YYPARSE_PARAM_DECL
@@ -582,7 +589,7 @@ YY_DECL_VARIABLES
 int
 yyparse (YYPARSE_PARAM_ARG)
      YYPARSE_PARAM_DECL
-{
+{[
   /* If reentrant, generate the variables here.  */
 #if YYPURE
   YY_DECL_VARIABLES
@@ -719,10 +726,10 @@ yyparse (YYPARSE_PARAM_ARG)
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
        if (! yyptr)
          goto yyoverflowlab;
-       YYSTACK_RELOCATE (short, yyss);
-       YYSTACK_RELOCATE (YYSTYPE, yyvs);
+       YYSTACK_RELOCATE (yyss);
+       YYSTACK_RELOCATE (yyvs);
 # if YYLSP_NEEDED
-       YYSTACK_RELOCATE (YYLTYPE, yyls);
+       YYSTACK_RELOCATE (yyls);
 # endif
 # undef YYSTACK_RELOCATE
        if (yyss1 != yyssa)
@@ -902,14 +909,14 @@ yyreduce:
     }
 #endif
   switch (yyn)
-    {
-      %%{actions}
+    ]{
+      b4_actions
     }
 
-/* Line %%{skeleton-line} of %%{skeleton}.  */
-#line %%{line} "%%{parser-file-name}"
+/* Line __line__ of __file__.  */
+#line __oline__
 \f
-  yyvsp -= yylen;
+[  yyvsp -= yylen;
   yyssp -= yylen;
 #if YYLSP_NEEDED
   yylsp -= yylen;
@@ -1136,6 +1143,42 @@ yyreturn:
     YYSTACK_FREE (yyss);
 #endif
   return yyresult;
-}
+]}
+
+b4_epilogue
+m4_if(b4_defines_flag, 0, [],
+[#output "b4_output_header_name"
+#ifndef b4_header_guard
+# define b4_header_guard
+
+b4_token_defines(b4_tokens)
+
+#ifndef YYSTYPE
+m4_ifdef([b4_stype_line],
+[#line b4_stype_line "b4_filename"
+])dnl
+typedef b4_stype
+yystype;
+# define YYSTYPE yystype
+#endif
+
+m4_if(b4_pure, [0],
+[extern YYSTYPE b4_prefix[]lval;])
+
+m4_if(b4_locations_flag, [0], [],
+[#ifndef YYLTYPE
+typedef struct yyltype
+{
+  int first_line;
+  int first_column;
+  int last_line;
+  int last_column;
+} yyltype;
+# define YYLTYPE yyltype
+#endif
 
-%%{epilogue}
+m4_if(b4_pure, [0],
+[extern YYLTYPE b4_prefix[]lloc;])
+])
+#endif /* not b4_header_guard */
+])