📄 yacc.c
字号:
m4_divert(-1) -*- C -*-# Yacc compatible skeleton for Bison# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004# Free Software Foundation, Inc.# This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.# This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.# You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA# 02111-1307 USA## ---------------- #### Default values. #### ---------------- ### Stack parameters.m4_define_default([b4_stack_depth_max], [10000])m4_define_default([b4_stack_depth_init], [200])## ------------------------ #### Pure/impure interfaces. #### ------------------------ ### b4_pure_if(IF-TRUE, IF-FALSE)# -----------------------------# Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise.m4_define([b4_Pure_if],[b4_pure_if([m4_ifset([b4_parse_param], [$1], [$2])], [$2])])# b4_yyerror_args# ---------------# Arguments passed to yyerror: user args plus yylloc.m4_define([b4_yyerror_args],[b4_Pure_if([b4_location_if([&yylloc, ])])dnlm4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])# b4_lex_param# ------------# Accumulate in b4_lex_param all the yylex arguments.# b4_lex_param arrives quoted twice, but we want to keep only one level.m4_define([b4_lex_param],m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnlb4_location_if([, [[YYLTYPE *], [&yylloc]]])m4_ifdef([b4_lex_param], [, ])])dnlm4_ifdef([b4_lex_param], b4_lex_param)))## ------------ #### Data Types. #### ------------ ### b4_int_type(MIN, MAX)# ---------------------# Return the smallest int type able to handle numbers ranging from# MIN to MAX (included). We overwrite the version from c.m4 which relies# on "signed char" which is not portable to old K&R compilers.m4_define([b4_int_type],[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char], b4_ints_in($@, [-128], [127]), [1], [yysigned_char], b4_ints_in($@, [0], [65535]), [1], [unsigned short int], b4_ints_in($@, [-32768], [32767]), [1], [short int], m4_eval([0 <= $1]), [1], [unsigned int], [int])])## ----------------- #### Semantic Values. #### ----------------- ### 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]))])## ----------- #### Locations. #### ----------- ### 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])@})])## --------------------------------------------------------- #### Defining symbol actions, e.g., printers and destructors. #### --------------------------------------------------------- ### We do want M4 expansion after # for CPP macros.m4_changecom()m4_divert(0)dnl@output @output_parser_name@b4_copyright([Skeleton parser for Yacc-like parsing with Bison], [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004])[/* 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. *//* 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. */]b4_identificationm4_if(b4_prefix[], [yy], [],[/* Substitute the variable and function names. */#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[]nerrsb4_location_if([#define yylloc b4_prefix[]lloc])])[]b4_token_defines(b4_tokens)[/* Copy the first part of user declarations. */]b4_pre_prologue[/* Enabling traces. */#ifndef YYDEBUG# define YYDEBUG ]b4_debug[#endif/* Enabling verbose error messages. */#ifdef YYERROR_VERBOSE# undef YYERROR_VERBOSE# define YYERROR_VERBOSE 1#else# define YYERROR_VERBOSE ]b4_error_verbose[#endif#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)]m4_ifdef([b4_stype],[b4_syncline([b4_stype_line], [b4_filename])typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE;/* Line __line__ of yacc.c. */b4_syncline([@oline@], [@ofile@])],[typedef int YYSTYPE;])[# define yystype YYSTYPE /* obsolescent; will be withdrawn */# define YYSTYPE_IS_DECLARED 1# define YYSTYPE_IS_TRIVIAL 1#endif]b4_location_if([#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)typedef struct YYLTYPE{ int first_line; int first_column; int last_line; int last_column;} YYLTYPE;# define yyltype YYLTYPE /* obsolescent; will be withdrawn */# define YYLTYPE_IS_DECLARED 1# define YYLTYPE_IS_TRIVIAL 1#endif])[/* Copy the second part of user declarations. */]b4_post_prologue/* Line __line__ of yacc.c. */b4_syncline([@oline@], [@ofile@])[#if ! defined (yyoverflow) || YYERROR_VERBOSE# ifndef YYFREE# define YYFREE free# endif# ifndef YYMALLOC# define YYMALLOC malloc# endif/* The parser invokes alloca or malloc; define the necessary symbols. */# ifdef YYSTACK_USE_ALLOCA# if YYSTACK_USE_ALLOCA# ifdef __GNUC__# define YYSTACK_ALLOC __builtin_alloca# else# define YYSTACK_ALLOC alloca# endif# endif# endif# ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)# else# if defined (__STDC__) || defined (__cplusplus)# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */# define YYSIZE_T size_t# endif# define YYSTACK_ALLOC YYMALLOC# define YYSTACK_FREE YYFREE# endif#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */#if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \ && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))/* A type that is properly aligned for any stack member. */union yyalloc{ short int yyss; YYSTYPE yyvs; ]b4_location_if([ YYLTYPE yyls;])dnl[};/* The size of the maximum gap between one aligned stack and the next. */# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)/* The size of an array large to enough to hold all stacks, each with N elements. */]b4_location_if([# define YYSTACK_BYTES(N) \ ((N) * (sizeof (short int) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM)],[# define YYSTACK_BYTES(N) \ ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM)])[/* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */# ifndef YYCOPY# if defined (__GNUC__) && 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(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0)#endif#if defined (__STDC__) || defined (__cplusplus) typedef signed char yysigned_char;#else typedef short int yysigned_char;#endif/* YYFINAL -- State number of the termination state. */#define YYFINAL ]b4_final_state_number[/* YYLAST -- Last index in YYTABLE. */#define YYLAST ]b4_last[/* YYNTOKENS -- Number of terminals. */#define YYNTOKENS ]b4_tokens_number[/* YYNNTS -- Number of nonterminals. */#define YYNNTS ]b4_nterms_number[/* YYNRULES -- Number of rules. */#define YYNRULES ]b4_rules_number[/* YYNRULES -- Number of states. */#define YYNSTATES ]b4_states_number[/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */#define YYUNDEFTOK ]b4_undef_token_number[#define YYMAXUTOK ]b4_user_token_number_max[#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */static const ]b4_int_type_for([b4_translate])[ yytranslate[] ={ ]b4_translate[};#if YYDEBUG/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */static const ]b4_int_type_for([b4_prhs])[ yyprhs[] ={ ]b4_prhs[};/* YYRHS -- A `-1'-separated list of the rules' RHS. */static const ]b4_int_type_for([b4_rhs])[ yyrhs[] ={ ]b4_rhs[};/* YYRLINE[YYN] -- source line where rule number YYN was defined. */static const ]b4_int_type_for([b4_rline])[ yyrline[] ={ ]b4_rline[};#endif#if YYDEBUG || YYERROR_VERBOSE/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */static const char *const yytname[] ={ ]b4_tname[};#endif# ifdef YYPRINT/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */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_int_type_for([b4_r1])[ yyr1[] ={ ]b4_r1[};/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */static const ]b4_int_type_for([b4_r2])[ yyr2[] ={ ]b4_r2[};/* 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 ]b4_int_type_for([b4_defact])[ yydefact[] ={ ]b4_defact[};/* YYDEFGOTO[NTERM-NUM]. */static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] ={ ]b4_defgoto[};/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */#define YYPACT_NINF ]b4_pact_ninf[static const ]b4_int_type_for([b4_pact])[ yypact[] ={ ]b4_pact[};/* YYPGOTO[NTERM-NUM]. */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. If YYTABLE_NINF, syntax error. */#define YYTABLE_NINF ]b4_table_ninf[static const ]b4_int_type_for([b4_table])[ yytable[] ={ ]b4_table[};static const ]b4_int_type_for([b4_check])[ yycheck[] ={ ]b4_check[};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -