⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c-.tab.c

📁 一个编译器的例子,基于c语言,在linux下开发 现在了简单的c语言例子
💻 C
📖 第 1 页 / 共 5 页
字号:
/* A Bison parser, made by GNU Bison 1.875.  *//* Skeleton parser for Yacc-like parsing with Bison,   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 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 0/* Using locations.  */#define YYLSP_NEEDED 0/* Tokens.  */#ifndef YYTOKENTYPE# define YYTOKENTYPE   /* Put the tokens into the symbol table, so that GDB and other debuggers      know about them.  */   enum yytokentype {     ID = 258,     INT_VAL = 259,     CHAR_VAL = 260,     FLT_VAL = 261,     HEX_VAL = 262,     EP_VAL = 263,     STRING = 264,     SIZEOF = 265,     PTR_OP = 266,     INC_OP = 267,     DEC_OP = 268,     LEFT_OP = 269,     RIGHT_OP = 270,     LE_OP = 271,     GE_OP = 272,     EQ_OP = 273,     NE_OP = 274,     PRN_OP = 275,     AND_OP = 276,     OR_OP = 277,     MUL_ASSIGN = 278,     DIV_ASSIGN = 279,     MOD_ASSIGN = 280,     ADD_ASSIGN = 281,     SUB_ASSIGN = 282,     LEFT_ASSIGN = 283,     RIGHT_ASSIGN = 284,     AND_ASSIGN = 285,     XOR_ASSIGN = 286,     OR_ASSIGN = 287,     CHAR = 288,     INT = 289,     FLOAT = 290,     DOUBLE = 291,     VOID = 292,     STRUCT = 293,     CASE = 294,     DEFAULT = 295,     IF = 296,     ELSE = 297,     SWITCH = 298,     WHILE = 299,     DO = 300,     FOR = 301,     GOTO = 302,     CONTINUE = 303,     BREAK = 304,     RETURN = 305,     PRINTLN = 306   };#endif#define ID 258#define INT_VAL 259#define CHAR_VAL 260#define FLT_VAL 261#define HEX_VAL 262#define EP_VAL 263#define STRING 264#define SIZEOF 265#define PTR_OP 266#define INC_OP 267#define DEC_OP 268#define LEFT_OP 269#define RIGHT_OP 270#define LE_OP 271#define GE_OP 272#define EQ_OP 273#define NE_OP 274#define PRN_OP 275#define AND_OP 276#define OR_OP 277#define MUL_ASSIGN 278#define DIV_ASSIGN 279#define MOD_ASSIGN 280#define ADD_ASSIGN 281#define SUB_ASSIGN 282#define LEFT_ASSIGN 283#define RIGHT_ASSIGN 284#define AND_ASSIGN 285#define XOR_ASSIGN 286#define OR_ASSIGN 287#define CHAR 288#define INT 289#define FLOAT 290#define DOUBLE 291#define VOID 292#define STRUCT 293#define CASE 294#define DEFAULT 295#define IF 296#define ELSE 297#define SWITCH 298#define WHILE 299#define DO 300#define FOR 301#define GOTO 302#define CONTINUE 303#define BREAK 304#define RETURN 305#define PRINTLN 306/* Copy the first part of user declarations.  */#line 1 "c-.y"#define YYDEBUG 1#include <stdlib.h>#include "struct.h"#include "stack.h"#include "compiler.c"symnode *curIDNode=(symnode *)0;symnode *curFuncNode=(symnode *)0;symnode *lastIDNode=(symnode *)0;/*symnode * TreeMatrix[TREE_X][TREE_Y];void initializeMatrix();void convertParseTree(symnode *,int);void convertPTVert();void printParseTree(symnode *);int printSymbolTable();symnode *setStrIndex(symnode *, int);symnode *pointSymTable(symnode *, symrec *);*//* Enabling traces.  */#ifndef YYDEBUG# define YYDEBUG 0#endif/* Enabling verbose error messages.  */#ifdef YYERROR_VERBOSE# undef YYERROR_VERBOSE# define YYERROR_VERBOSE 1#else# define YYERROR_VERBOSE 0#endif#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)#line 24 "c-.y"typedef union YYSTYPE {              /* define stack type */  char  *val;  symnode *symptr;} YYSTYPE;/* Line 191 of yacc.c.  */#line 205 "c-.tab.c"# define yystype YYSTYPE /* obsolescent; will be withdrawn */# define YYSTYPE_IS_DECLARED 1# define YYSTYPE_IS_TRIVIAL 1#endif/* Copy the second part of user declarations.  *//* Line 214 of yacc.c.  */#line 217 "c-.tab.c"#if ! defined (yyoverflow) || YYERROR_VERBOSE/* The parser invokes alloca or malloc; define the necessary symbols.  */# if YYSTACK_USE_ALLOCA#  define YYSTACK_ALLOC alloca# else#  ifndef YYSTACK_USE_ALLOCA#   if defined (alloca) || defined (_ALLOCA_H)#    define YYSTACK_ALLOC alloca#   else#    ifdef __GNUC__#     define YYSTACK_ALLOC __builtin_alloca#    endif#   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 malloc#  define YYSTACK_FREE free# endif#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */#if (! defined (yyoverflow) \     && (! defined (__cplusplus) \	 || (YYSTYPE_IS_TRIVIAL)))/* A type that is properly aligned for any stack member.  */union yyalloc{  short yyss;  YYSTYPE yyvs;  };/* 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) + sizeof (YYSTYPE))				\      + YYSTACK_GAP_MAXIMUM)/* 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(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 yysigned_char;#endif/* YYFINAL -- State number of the termination state. */#define YYFINAL  35/* YYLAST -- Last index in YYTABLE.  */#define YYLAST   920/* YYNTOKENS -- Number of terminals. */#define YYNTOKENS  75/* YYNNTS -- Number of nonterminals. */#define YYNNTS  61/* YYNRULES -- Number of rules. */#define YYNRULES  181/* YYNRULES -- Number of states. */#define YYNSTATES  312/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */#define YYUNDEFTOK  2#define YYMAXUTOK   306#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,    62,     2,     2,     2,    64,    58,     2,      52,    53,    59,    60,    57,    61,    56,    63,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,    70,    72,      65,    71,    66,    69,     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,    54,     2,    55,    67,     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,    73,    68,    74,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -