X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/62a3e4f0c54505834cb89c40726771ad32aabb27..82b6cb3fb20b5036b201a07c4ea1b2a59b904d01:/data/bison.simple?ds=sidebyside diff --git a/data/bison.simple b/data/bison.simple index 255a3865..14615bf7 100644 --- a/data/bison.simple +++ b/data/bison.simple @@ -1,4 +1,4 @@ -m4_divert(-1) +m4_divert(-1) -*- C -*- # b4_sint_type(MAX) # ----------------- @@ -20,6 +20,36 @@ m4_define([b4_uint_type], [m4_fatal([no unsigned int type for $1])])]) +# b4_lhs_value([TYPE]) +# -------------------- +# Expansion of $$. +m4_define([b4_lhs_value], +[yyval[]m4_ifval([$1], [.$1])]) + + +# b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) +# -------------------------------------- +# Expansion of $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]) m4_define_default([b4_output_parser_suffix], @@ -89,6 +119,13 @@ m4_divert(0)dnl It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ +/* 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 @@ -113,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 @@ -135,6 +172,7 @@ m4_ifdef([b4_stype_line], ])dnl typedef b4_stype yystype; # define YYSTYPE yystype +# define YYSTYPE_IS_TRIVIAL 1 #endif #ifndef YYLTYPE @@ -146,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__ +/* 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. */ @@ -187,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 @@ -205,12 +246,12 @@ 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 /* Copy COUNT objects from FROM to TO. The source and destination do @@ -225,7 +266,7 @@ union yyalloc { \ register YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ + (To)[[yyi]] = (From)[[yyi]]; \ } \ while (0) # endif @@ -247,7 +288,7 @@ union yyalloc } \ while (0) -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ +#endif /* Tokens. */ b4_token_defines(b4_tokens) @@ -265,11 +306,14 @@ 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 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) <= b4_maxtok ? yytranslate[[x]] : b4_nsym) +#define YYTRANSLATE(X) \ + ((unsigned)(X) <= YYMAXUTOK ? yytranslate[[X]] : YYUNDEFTOK) /* YYTRANSLATE[[YYLEX]] -- Bison symbol number corresponding to YYLEX. */ static const yy_token_number_type yytranslate[[]] = @@ -315,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 }; @@ -466,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) @@ -735,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; @@ -750,13 +797,14 @@ yyparse (YYPARSE_PARAM_ARG) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); -# if YYLSP_NEEDED +# if YYLSP_NEEDED YYSTACK_RELOCATE (yyls); -# endif -# undef YYSTACK_RELOCATE +# endif +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } +# endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; @@ -936,7 +984,7 @@ yyreduce: } /* Line __line__ of __file__. */ -#line __oline__ +#line __oline__ "__ofile__" [ yyvsp -= yylen; yyssp -= yylen; @@ -1055,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;