X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/be2a1a68efe93f7046f77b81346e4c740c14fb40..0f8d586a9f9f8def762cd2aedfe57f223a9c88e3:/data/bison.simple diff --git a/data/bison.simple b/data/bison.simple index 80cf81ae..668d528a 100644 --- a/data/bison.simple +++ b/data/bison.simple @@ -1,11 +1,5 @@ m4_divert(-1) -# m4_define_default(MACRO, VALUE) -# ------------------------------- -# Define MACRO to VALUE, unless already defined. -m4_define([m4_define_default], -[m4_ifdef([$1], [], [m4_define($@)])]) - m4_define_default([b4_input_suffix], [.y]) m4_define_default([b4_output_parser_suffix], @@ -25,6 +19,22 @@ 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 @@ -100,6 +110,9 @@ b4_prologue #endif #ifndef YYSTYPE +m4_ifdef([b4_stype_line], +[#line b4_stype_line "b4_filename" +])dnl typedef b4_stype yystype; # define YYSTYPE yystype #endif @@ -125,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. */ @@ -153,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 /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T std::size_t -# else -# ifdef __STDC__ -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif +# if defined (__STDC__) || defined (__cplusplus) +# include /* 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. */ @@ -191,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) @@ -211,7 +230,7 @@ union yyalloc #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ /* Tokens. */ -b4_tokendef +b4_token_defines(b4_tokens) /* YYFINAL -- State number of the termination state. */ #define YYFINAL b4_final @@ -333,14 +352,9 @@ static const short yycheck[[]] = # define YYSIZE_T size_t #endif #if ! defined (YYSIZE_T) -# ifdef __cplusplus -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T std::size_t -# else -# ifdef __STDC__ -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t # endif #endif #if ! defined (YYSIZE_T) @@ -421,12 +435,8 @@ while (0) #if YYDEBUG # ifndef YYFPRINTF -# ifdef __cplusplus -# include /* INFRINGES ON USER NAME SPACE */ -# else -# include /* INFRINGES ON USER NAME SPACE */ -# endif -# define YYFPRINTF YYSTD (fprintf) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ @@ -463,33 +473,6 @@ int yydebug; -#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 @@ -552,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 @@ -743,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) @@ -1168,9 +1151,12 @@ m4_if(b4_defines_flag, 0, [], #ifndef b4_header_guard # define b4_header_guard -b4_tokendef +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