]> git.saurik.com Git - bison.git/blobdiff - data/bison.simple
* src/reader.c (parse_braces): Merge into...
[bison.git] / data / bison.simple
index 87f4188dfbb4cb6a6edc6e65b1ee7de155d02abf..f7127a0cbc4fbc083c5ff8605409b69764608f0b 100644 (file)
@@ -1,4 +1,54 @@
-m4_divert(-1)
+m4_divert(-1)                                                       -*- C -*-
+
+# b4_sint_type(MAX)
+# -----------------
+# Return the smallest signed int type able to handle the number MAX.
+m4_define([b4_sint_type],
+[m4_if(m4_eval([$1 <= 127]),        [1], [signed char],
+       m4_eval([$1 <= 32767]),      [1], [signed short],
+       m4_eval([$1 <= 2147483647]), [1], [signed int],
+       [m4_fatal([no signed int type for $1])])])
+
+
+# b4_uint_type(MAX)
+# -----------------
+# Return the smallest unsigned int type able to handle the number MAX.
+m4_define([b4_uint_type],
+[m4_if(m4_eval([$1 <= 255]),        [1], [unsigned char],
+       m4_eval([$1 <= 65535]),      [1], [unsigned short],
+       m4_eval([$1 <= 4294967295]), [1], [unsigned int],
+       [m4_fatal([no unsigned int type for $1])])])
+
+
+# b4_lhs_value([TYPE])
+# --------------------
+# Expansion of $<TYPE>$.
+m4_define([b4_lhs_value],
+[yyval[]m4_ifval([$1], [.$1])])
+
+
+# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
+# --------------------------------------
+# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
+# symbols on RHS.
+m4_define([b4_rhs_value],
+[yyvsp@<:@m4_eval([$2 - $1])@:>@m4_ifval([$3], [.$3])])
+
+
+# b4_lhs_location()
+# -----------------
+# Expansion of @$.
+m4_define([b4_lhs_location],
+[yyloc])
+
+
+# b4_rhs_location(RULE-LENGTH, NUM)
+# ---------------------------------
+# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
+# on RHS.
+m4_define([b4_rhs_location],
+[yylsp@<:@m4_eval([$2 - $1])@:>@])
+
 
 m4_define_default([b4_input_suffix], [.y])
 
@@ -66,8 +116,15 @@ m4_divert(0)dnl
 
 /* This is the parser code that is written into each bison parser when
    the %semantic_parser declaration is not specified in the grammar.
-   It was written by Richard Stallman by simplifying the hairy parser
-   used when %semantic_parser is specified.  */
+   It was written by Richard Stallman by simplifying the original so
+   called ``semantic'' parser.  */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+   infringing on user name space.  This should be done even for local
+   variables, as they might otherwise be expanded by user macros.
+   There are some unavoidable exceptions within include files to
+   define necessary library symbols; they are noted "INFRINGES ON
+   USER NAME SPACE" below.  */
 
 /* Identify Bison output.  */
 #define YYBISON        1
@@ -93,8 +150,8 @@ m4_if(b4_prefix[], [yy], [],
 #endif
 ])
 
-/* Copy the user declarations.  */
-b4_prologue
+/* Copy the first part of user declarations.  */
+b4_pre_prologue
 
 /* Enabling traces.  */
 #ifndef YYDEBUG
@@ -110,8 +167,12 @@ b4_prologue
 #endif
 
 #ifndef YYSTYPE
+m4_ifdef([b4_stype_line],
+[#line b4_stype_line "b4_filename"
+])dnl
 typedef b4_stype yystype;
 # define YYSTYPE yystype
+# define YYSTYPE_IS_TRIVIAL 1
 #endif
 
 #ifndef YYLTYPE
@@ -123,19 +184,16 @@ typedef struct yyltype
   int last_column;
 } yyltype;
 # define YYLTYPE b4_ltype
+# define YYLTYPE_IS_TRIVIAL 1
 #endif
 
-/* Line __line__ of __file__.  */
-#line __oline__ "b4_output_parser_name"
+/* Copy the second part of user declarations.  */
+b4_post_prologue
 
-/* All symbols defined below should begin with yy or YY, to avoid
-   infringing on user name space.  This should be done even for local
-   variables, as they might otherwise be expanded by user macros.
-   There are some unavoidable exceptions within include files to
-   define necessary library symbols; they are noted "INFRINGES ON
-   USER NAME SPACE" below.  */
+/* Line __line__ of __file__.  */
+#line __oline__ "__ofile__"
 
-#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
+#if ! defined (yyoverflow) || YYERROR_VERBOSE
 
 /* The parser invokes alloca or malloc; define the necessary symbols.  */
 
@@ -164,6 +222,12 @@ typedef struct yyltype
 #  define YYSTACK_ALLOC malloc
 #  define YYSTACK_FREE free
 # endif
+#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
+
+
+#if (! defined (yyoverflow) \
+     && (! defined (__cplusplus) \
+        || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
 
 /* A type that is properly aligned for any stack member.  */
 union yyalloc
@@ -182,32 +246,49 @@ union yyalloc
    N elements.  */
 # if YYLSP_NEEDED
 #  define YYSTACK_BYTES(N) \
-    ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))      \
-     + 2 * YYSTACK_GAP_MAX)
+     ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))     \
+      + 2 * YYSTACK_GAP_MAX)
 # else
 #  define YYSTACK_BYTES(N) \
-    ((N) * (sizeof (short) + sizeof (YYSTYPE))                         \
-     + YYSTACK_GAP_MAX)
+     ((N) * (sizeof (short) + sizeof (YYSTYPE))                                \
+      + 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)
 
-#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
+#endif
 
 /* Tokens.  */
 b4_token_defines(b4_tokens)
@@ -225,13 +306,17 @@ b4_token_defines(b4_tokens)
 #define YYNRULES  b4_nrules
 /* YYNRULES -- Number of states. */
 #define YYNSTATES  b4_nstates
-#define YYMAXUTOK  b4_maxtok
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
-#define YYTRANSLATE(x) ((unsigned)(x) <= b4_maxtok ? yytranslate[[x]] : b4_nsym)
+#define YYUNDEFTOK  b4_undef_token_number
+#define YYMAXUTOK   b4_user_token_number_max
+
+typedef b4_uint_type(b4_token_number_max) yy_token_number_type;
+#define YYTRANSLATE(X) \
+  ((unsigned)(X) <= YYMAXUTOK ? yytranslate[[X]] : YYUNDEFTOK)
 
 /* YYTRANSLATE[[YYLEX]] -- Bison symbol number corresponding to YYLEX.  */
-static const char yytranslate[[]] =
+static const yy_token_number_type yytranslate[[]] =
 {
   b4_translate
 };
@@ -245,7 +330,8 @@ static const short yyprhs[[]] =
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const short yyrhs[[]] =
+typedef b4_sint_type(b4_rhs_number_max) yyrhs_t;
+static const yyrhs_t yyrhs[[]] =
 {
   b4_rhs
 };
@@ -273,7 +359,7 @@ static const short yytoknum[[]] =
 };
 
 /* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives.  */
-static const short yyr1[[]] =
+static const yy_token_number_type yyr1[[]] =
 {
   b4_r1
 };
@@ -424,8 +510,8 @@ do {                                                \
   if (yydebug)                                 \
     YYFPRINTF Args;                            \
 } while (0)
-/* Nonzero means print parse trace.  Since this is uninitialized, it
-   does not stop multiple parsers from coexisting.  */
+/* Nonzero means print parse trace.  It is left uninitialized so that
+   multiple parsers can coexist.  */
 int yydebug;
 #else /* !YYDEBUG */
 # define YYDPRINTF(Args)
@@ -453,33 +539,6 @@ int yydebug;
 
 \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
@@ -720,6 +779,9 @@ yyparse (YYPARSE_PARAM_ARG)
        yyvs = yyvs1;
       }
 #else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+      goto yyoverflowlab;
+# else
       /* Extend the stack our own way.  */
       if (yystacksize >= YYMAXDEPTH)
        goto yyoverflowlab;
@@ -733,15 +795,16 @@ yyparse (YYPARSE_PARAM_ARG)
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
        if (! yyptr)
          goto yyoverflowlab;
-       YYSTACK_RELOCATE (short, yyss);
-       YYSTACK_RELOCATE (YYSTYPE, yyvs);
-# if YYLSP_NEEDED
-       YYSTACK_RELOCATE (YYLTYPE, yyls);
-# endif
-# undef YYSTACK_RELOCATE
+       YYSTACK_RELOCATE (yyss);
+       YYSTACK_RELOCATE (yyvs);
+#  if YYLSP_NEEDED
+       YYSTACK_RELOCATE (yyls);
+#  endif
+#  undef YYSTACK_RELOCATE
        if (yyss1 != yyssa)
          YYSTACK_FREE (yyss1);
       }
+# endif
 #endif /* no yyoverflow */
 
       yyssp = yyss + yysize - 1;
@@ -921,7 +984,7 @@ yyreduce:
     }
 
 /* Line __line__ of __file__.  */
-#line __oline__ "b4_output_parser_name"
+#line __oline__ "__ofile__"
 \f
 [  yyvsp -= yylen;
   yyssp -= yylen;
@@ -1040,7 +1103,7 @@ yyerrlab1:
   /* Else will try to reuse lookahead token after shifting the error
      token.  */
 
-  yyerrstatus = 3;             /* Each real token shifted decrements this.  */
+  yyerrstatus = 3;     /* Each real token shifted decrements this.  */
 
   goto yyerrhandle;
 
@@ -1161,6 +1224,9 @@ m4_if(b4_defines_flag, 0, [],
 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