📄 parse-gram.c
字号:
/* A Bison parser, made by GNU Bison 2.0. *//* Skeleton parser for Yacc-like parsing with 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, 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. *//* 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. *//* Identify Bison output. */#define YYBISON 1/* Skeleton name. */#define YYSKELETON_NAME "yacc.c"/* Pure parsers. */#define YYPURE 1/* Using locations. */#define YYLSP_NEEDED 1/* Substitute the variable and function names. */#define yyparse gram_parse#define yylex gram_lex#define yyerror gram_error#define yylval gram_lval#define yychar gram_char#define yydebug gram_debug#define yynerrs gram_nerrs#define yylloc gram_lloc/* Tokens. */#ifndef YYTOKENTYPE# define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { GRAM_EOF = 0, STRING = 258, INT = 259, PERCENT_TOKEN = 260, PERCENT_NTERM = 261, PERCENT_TYPE = 262, PERCENT_DESTRUCTOR = 263, PERCENT_PRINTER = 264, PERCENT_UNION = 265, PERCENT_LEFT = 266, PERCENT_RIGHT = 267, PERCENT_NONASSOC = 268, PERCENT_PREC = 269, PERCENT_DPREC = 270, PERCENT_MERGE = 271, PERCENT_DEBUG = 272, PERCENT_DEFAULT_PREC = 273, PERCENT_DEFINE = 274, PERCENT_DEFINES = 275, PERCENT_ERROR_VERBOSE = 276, PERCENT_EXPECT = 277, PERCENT_EXPECT_RR = 278, PERCENT_FILE_PREFIX = 279, PERCENT_GLR_PARSER = 280, PERCENT_INITIAL_ACTION = 281, PERCENT_LEX_PARAM = 282, PERCENT_LOCATIONS = 283, PERCENT_NAME_PREFIX = 284, PERCENT_NO_DEFAULT_PREC = 285, PERCENT_NO_LINES = 286, PERCENT_NONDETERMINISTIC_PARSER = 287, PERCENT_OUTPUT = 288, PERCENT_PARSE_PARAM = 289, PERCENT_PURE_PARSER = 290, PERCENT_SKELETON = 291, PERCENT_START = 292, PERCENT_TOKEN_TABLE = 293, PERCENT_VERBOSE = 294, PERCENT_YACC = 295, TYPE = 296, EQUAL = 297, SEMICOLON = 298, PIPE = 299, ID = 300, ID_COLON = 301, PERCENT_PERCENT = 302, PROLOGUE = 303, EPILOGUE = 304, BRACED_CODE = 305 };#endif#define GRAM_EOF 0#define STRING 258#define INT 259#define PERCENT_TOKEN 260#define PERCENT_NTERM 261#define PERCENT_TYPE 262#define PERCENT_DESTRUCTOR 263#define PERCENT_PRINTER 264#define PERCENT_UNION 265#define PERCENT_LEFT 266#define PERCENT_RIGHT 267#define PERCENT_NONASSOC 268#define PERCENT_PREC 269#define PERCENT_DPREC 270#define PERCENT_MERGE 271#define PERCENT_DEBUG 272#define PERCENT_DEFAULT_PREC 273#define PERCENT_DEFINE 274#define PERCENT_DEFINES 275#define PERCENT_ERROR_VERBOSE 276#define PERCENT_EXPECT 277#define PERCENT_EXPECT_RR 278#define PERCENT_FILE_PREFIX 279#define PERCENT_GLR_PARSER 280#define PERCENT_INITIAL_ACTION 281#define PERCENT_LEX_PARAM 282#define PERCENT_LOCATIONS 283#define PERCENT_NAME_PREFIX 284#define PERCENT_NO_DEFAULT_PREC 285#define PERCENT_NO_LINES 286#define PERCENT_NONDETERMINISTIC_PARSER 287#define PERCENT_OUTPUT 288#define PERCENT_PARSE_PARAM 289#define PERCENT_PURE_PARSER 290#define PERCENT_SKELETON 291#define PERCENT_START 292#define PERCENT_TOKEN_TABLE 293#define PERCENT_VERBOSE 294#define PERCENT_YACC 295#define TYPE 296#define EQUAL 297#define SEMICOLON 298#define PIPE 299#define ID 300#define ID_COLON 301#define PERCENT_PERCENT 302#define PROLOGUE 303#define EPILOGUE 304#define BRACED_CODE 305/* Copy the first part of user declarations. */#line 1 "parse-gram.y"/* Bison Grammar Parser -*- C -*- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. 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*/#include "system.h"#include "complain.h"#include "conflicts.h"#include "files.h"#include "getargs.h"#include "gram.h"#include "muscle_tab.h"#include "output.h"#include "reader.h"#include "symlist.h"#define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N)static YYLTYPE lloc_default (YYLTYPE const *, int);#define YY_LOCATION_PRINT(File, Loc) \ location_print (File, Loc)/* Request detailed syntax error messages, and pass them to GRAM_ERROR. FIXME: depends on the undocumented availability of YYLLOC. */#undef yyerror#define yyerror(Msg) \ gram_error (&yylloc, Msg)static void gram_error (location const *, char const *);#define YYPRINT(File, Type, Value) \ print_token_value (File, Type, &Value)static void print_token_value (FILE *, int, YYSTYPE const *);static void add_param (char const *, char *, location);symbol_class current_class = unknown_sym;uniqstr current_type = 0;symbol *current_lhs;location current_lhs_location;assoc current_assoc;int current_prec = 0;/* Enabling traces. */#ifndef YYDEBUG# define YYDEBUG 1#endif/* Enabling verbose error messages. */#ifdef YYERROR_VERBOSE# undef YYERROR_VERBOSE# define YYERROR_VERBOSE 1#else# define YYERROR_VERBOSE 1#endif#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)#line 81 "parse-gram.y"typedef union YYSTYPE { symbol *symbol; symbol_list *list; int integer; char *chars; assoc assoc; uniqstr uniqstr;} YYSTYPE;/* Line 190 of yacc.c. */#line 256 "parse-gram.c"# define yystype YYSTYPE /* obsolescent; will be withdrawn */# define YYSTYPE_IS_DECLARED 1# define YYSTYPE_IS_TRIVIAL 1#endif#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. *//* Line 213 of yacc.c. */#line 280 "parse-gram.c"#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) \ || (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; YYLTYPE yyls;};/* 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. */# define YYSTACK_BYTES(N) \ ((N) * (sizeof (short int) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * 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 3/* YYLAST -- Last index in YYTABLE. */#define YYLAST 158/* YYNTOKENS -- Number of terminals. */#define YYNTOKENS 51/* YYNNTS -- Number of nonterminals. */#define YYNNTS 25/* YYNRULES -- Number of rules. */#define YYNRULES 79/* YYNRULES -- Number of states. */#define YYNSTATES 108/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */#define YYUNDEFTOK 2#define YYMAXUTOK 305#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */static const unsigned char yytranslate[] ={ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50};#if YYDEBUG/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */static const unsigned char yyprhs[] ={ 0, 0, 3, 8, 9, 12, 14, 16, 18, 22, 24, 26, 29, 32, 36, 38, 40, 42, 44, 48, 50, 52, 56, 58, 60, 63, 65, 67, 69, 71, 73, 75, 78, 80, 83, 86, 88, 90, 91, 95, 96, 100, 104, 108, 110, 112, 114, 115, 117, 119, 122, 124, 126, 129, 132, 136, 138, 141, 143, 146, 148, 151, 154, 155, 159, 161, 165, 168, 169, 172, 175, 179, 183, 187, 189, 191, 193, 195, 197, 198};/* YYRHS -- A `-1'-separated list of the rules' RHS. */static const yysigned_char yyrhs[] ={ 52, 0, -1, 53, 47, 65, 75, -1, -1, 53, 54, -1, 55, -1, 48, -1, 17, -1, 19, 74, 74, -1, 20, -1, 21, -1, 22, 4, -1, 23, 4, -1, 24, 42, 74, -1, 25, -1, 26, -1, 27, -1, 28, -1, 29, 42, 74, -1, 31, -1, 32, -1, 33, 42, 74, -1, 34, -1, 35, -1, 36, 74, -1, 38, -1, 39, -1, 40, -1, 43, -1, 59, -1, 56, -1, 37, 71, -1, 10, -1, 8, 62, -1, 9, 62, -1, 18, -1, 30, -1, -1, 6, 57, 64, -1, -1, 5, 58, 64, -1, 7, 41, 62, -1, 60, 61, 62, -1, 11, -1, 12, -1, 13, -1, -1, 41, -1, 71, -1, 62, 71, -1, 41, -1, 45, -1, 45, 4, -1, 45, 73, -1, 45, 4, 73, -1, 63, -1, 64, 63, -1, 66, -1, 65, 66, -1, 67, -1, 55, 43, -1, 1, 43, -1, -1, 46, 68, 69, -1, 70, -1, 69, 44, 70, -1, 69, 43, -1, -1, 70, 71, -1, 70, 72, -1, 70, 14, 71, -1, 70, 15, 4, -1, 70, 16, 41, -1, 45, -1, 73, -1, 50, -1, 3, -1, 3, -1, -1, 47, 49, -1};/* YYRLINE[YYN] -- source line where rule number YYN was defined. */static const unsigned short int yyrline[] ={ 0, 174, 174, 182, 184, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 202, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 222, 223, 224, 228, 234, 241, 248, 252, 259, 259, 264, 264, 269, 279, 294, 295, 296, 300, 301, 307, 308, 313, 317, 322, 328, 334, 345, 346, 355, 356, 362, 363, 368, 375, 375, 379, 380, 381, 386, 387, 389, 391, 393, 395, 400, 401, 405, 411, 420, 427, 429};#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[] ={ "\"end of file\"", "error", "$undefined", "\"string\"", "\"integer\"", "\"%token\"", "\"%nterm\"", "\"%type\"", "\"%destructor {...}\"", "\"%printer {...}\"", "\"%union {...}\"", "\"%left\"", "\"%right\"", "\"%nonassoc\"", "\"%prec\"", "\"%dprec\"", "\"%merge\"", "\"%debug\"", "\"%default-prec\"", "\"%define\"", "\"%defines\"", "\"%error-verbose\"", "\"%expect\"", "\"%expect-rr\"", "\"%file-prefix\"", "\"%glr-parser\"", "\"%initial-action {...}\"", "\"%lex-param {...}\"", "\"%locations\"", "\"%name-prefix\"", "\"%no-default-prec\"", "\"%no-lines\"", "\"%nondeterministic-parser\"", "\"%output\"", "\"%parse-param {...}\"", "\"%pure-parser\"", "\"%skeleton\"", "\"%start\"", "\"%token-table\"", "\"%verbose\"", "\"%yacc\"", "\"type\"", "\"=\"", "\";\"", "\"|\"", "\"identifier\"", "\"identifier:\"", "\"%%\"", "\"%{...%}\"", "\"epilogue\"", "\"{...}\"", "$accept", "input", "declarations", "declaration", "grammar_declaration", "symbol_declaration", "@1", "@2", "precedence_declaration", "precedence_declarator", "type.opt", "symbols.1", "symbol_def", "symbol_defs.1", "grammar", "rules_or_grammar_declaration", "rules", "@3", "rhses.1", "rhs", "symbol", "action", "string_as_id", "string_content", "epilogue.opt", 0};#endif# ifdef YYPRINT/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */static const unsigned short int yytoknum[] ={ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -