/* A Bison parser, made by GNU Bison 3.0.4. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2015 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 3 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, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton 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 /* Bison version. */ #define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Copy the first part of user declarations. */ #line 1 "mud.y" /* yacc.c:339 */ /* * $Id: mud.y,v 1.20 2012/06/10 13:07:35 dredd Exp $ * * Shattered Mud Language. * * An LPC derivative language. * * A word on the type hacks below * o designed to minimise changes the rest of the system * (this will be fixed in due course). * o Assume 32 bit ints. * top 8 bits struct no (max 255 structs) * next 8 bits (pointer depth max 255) * next 8 bits (special types static, private etc) * next 8 bits (basic types) * * (should be done using a struct; driver should support * a fully "distributable" type system - these will all * be done when I work out how :-) * * Geoff Wong (C) 1993, 1999 */ #include #include #include #include #include #include "stack.h" #include "opcodes.h" #include "lpc.h" #include "lexer.h" #include "build.h" #include "lexical.h" #include "consts.h" /* runtime stuff */ #include "../runtime/hash.h" #define YYMAXDEPTH 600 struct field { unsigned int type; short offset; }; Val * find_const2(Class ** io, Shared *s); void yyerror(), free_local_names_from(); extern int yylex(); void init_globals(), print_type(int), free_locals(); void free_type_list(); int variable_count; /* global vars */ int static_variable_flag; extern char * zero; Func * prog; extern int current_line, uinstr, puinstr; extern Obj * Emulate; int lang_debug = 0; int last_type = 0; /* * 'inherit_file' is used as a flag. If it is set to a string * after yyparse(), this string should be loaded as an object, * and the original object must be loaded again. * 'inherit_ob' will point to the super class object. This value is saved * so that load_object() can set up pointers to it. */ extern char * current_file ; extern Shared ** inherit_file ; int file_number = 0, inherit_number = 0 ; Class ** inherit_ob = NULL ; #define MAX_BLOCK_DEPTH 16 /* big! */ int labelstack[100]; int switchstack[MAX_BLOCK_DEPTH]; int switch_depth = 0; int LD = 0; union { float r; int i; lexar * s; } ultima, penultima; int block_depth = 0, max_locals = 0; int num_args, current_type = 0; int no_of_classes = 0; Func *prog_head = 0, *CPD = 0; Func *initialise_func = 0; Val **global_table = 0; CVal **constant_table = 0; struct var_def *arg_head = 0; /* globals stuff */ struct var_def * global_head = 0, * global_tail = 0 ; int num_globals = 0; int num_constants = 0; /* local variable stuff */ struct var_def *local_head = 0; int num_locals; int num_block_locals[MAX_BLOCK_DEPTH]; #define STRING_BLOCK 100 #define INITIAL_FUNC_SIZE 200 #line 198 "y.tab.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus # define YY_NULLPTR nullptr # else # define YY_NULLPTR 0 # endif # endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* In a future release of Bison, this section will be replaced by #include "y.tab.h". */ #ifndef YY_YY_Y_TAB_H_INCLUDED # define YY_YY_Y_TAB_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif #if YYDEBUG extern int yydebug; #endif /* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { TOK_STATIC = 258, TOK_PRIVATE = 259, TOK_TYPE = 260, TOK_CLASS = 261, TOK_SELF = 262, TOK_ARRAY = 263, TOK_OBJECT = 264, TOK_STRING_DECL = 265, TOK_REALT = 266, TOK_INT = 267, TOK_NUMBER = 268, TOK_STRING = 269, TOK_REAL = 270, TOK_SWITCH = 271, TOK_CASE = 272, TOK_DEFAULT = 273, TOK_IDENTIFIER = 274, TOK_TYNAME = 275, TOK_NEW = 276, TOK_VOID = 277, TOK_INHERIT = 278, TOK_COLON_COLON = 279, TOK_ENUM = 280, TOK_AS = 281, TOK_IMPORT = 282, TOK_END = 283, TOK_MODULE = 284, TOK_CATCH = 285, TOK_THROW = 286, TOK_GENERIC = 287, TOK_ABSTRACT = 288, TOK_DOTDOT = 289, TOK_LEFT_ARR = 290, TOK_RIGHT_ARR = 291, TOK_IF = 292, TOK_THEN = 293, TOK_ELSE = 294, TOK_WHILE = 295, TOK_DO = 296, TOK_FOR = 297, TOK_BREAK = 298, TOK_CONTINUE = 299, TOK_RETURN = 300, TOK_CONST = 301, TOK_LSH_EQ = 302, TOK_RSH_EQ = 303, TOK_LARROW = 304, TOK_AND_EQ = 305, TOK_OR_EQ = 306, TOK_XOR_EQ = 307, TOK_ADD_EQ = 308, TOK_SUB_EQ = 309, TOK_MULT_EQ = 310, TOK_DIV_EQ = 311, TOK_MOD_EQ = 312, OPASSIGN = 313, TOK_LOR = 314, TOK_LAND = 315, TOK_EQ = 316, TOK_NE = 317, TOK_GE = 318, TOK_LE = 319, TOK_LSH = 320, TOK_RSH = 321, POSTINC = 322, POSTDEC = 323, TOK_INC = 324, TOK_DEC = 325, UMINUS = 326, TOK_ARROW = 327 }; #endif /* Tokens. */ #define TOK_STATIC 258 #define TOK_PRIVATE 259 #define TOK_TYPE 260 #define TOK_CLASS 261 #define TOK_SELF 262 #define TOK_ARRAY 263 #define TOK_OBJECT 264 #define TOK_STRING_DECL 265 #define TOK_REALT 266 #define TOK_INT 267 #define TOK_NUMBER 268 #define TOK_STRING 269 #define TOK_REAL 270 #define TOK_SWITCH 271 #define TOK_CASE 272 #define TOK_DEFAULT 273 #define TOK_IDENTIFIER 274 #define TOK_TYNAME 275 #define TOK_NEW 276 #define TOK_VOID 277 #define TOK_INHERIT 278 #define TOK_COLON_COLON 279 #define TOK_ENUM 280 #define TOK_AS 281 #define TOK_IMPORT 282 #define TOK_END 283 #define TOK_MODULE 284 #define TOK_CATCH 285 #define TOK_THROW 286 #define TOK_GENERIC 287 #define TOK_ABSTRACT 288 #define TOK_DOTDOT 289 #define TOK_LEFT_ARR 290 #define TOK_RIGHT_ARR 291 #define TOK_IF 292 #define TOK_THEN 293 #define TOK_ELSE 294 #define TOK_WHILE 295 #define TOK_DO 296 #define TOK_FOR 297 #define TOK_BREAK 298 #define TOK_CONTINUE 299 #define TOK_RETURN 300 #define TOK_CONST 301 #define TOK_LSH_EQ 302 #define TOK_RSH_EQ 303 #define TOK_LARROW 304 #define TOK_AND_EQ 305 #define TOK_OR_EQ 306 #define TOK_XOR_EQ 307 #define TOK_ADD_EQ 308 #define TOK_SUB_EQ 309 #define TOK_MULT_EQ 310 #define TOK_DIV_EQ 311 #define TOK_MOD_EQ 312 #define OPASSIGN 313 #define TOK_LOR 314 #define TOK_LAND 315 #define TOK_EQ 316 #define TOK_NE 317 #define TOK_GE 318 #define TOK_LE 319 #define TOK_LSH 320 #define TOK_RSH 321 #define POSTINC 322 #define POSTDEC 323 #define TOK_INC 324 #define TOK_DEC 325 #define UMINUS 326 #define TOK_ARROW 327 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { #line 149 "mud.y" /* yacc.c:355 */ Func *lnode; int number; char *string; Shared * shared; float real; lexar *lexstr; Val * val; #line 392 "y.tab.c" /* yacc.c:355 */ }; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif extern YYSTYPE yylval; int yyparse (void); #endif /* !YY_YY_Y_TAB_H_INCLUDED */ /* Copy the second part of user declarations. */ #line 409 "y.tab.c" /* yacc.c:358 */ #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #else typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ # define YY_(Msgid) Msgid # endif #endif #ifndef YY_ATTRIBUTE # if (defined __GNUC__ \ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C # define YY_ATTRIBUTE(Spec) __attribute__(Spec) # else # define YY_ATTRIBUTE(Spec) /* empty */ # endif #endif #ifndef YY_ATTRIBUTE_PURE # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) #endif #ifndef YY_ATTRIBUTE_UNUSED # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif #if !defined _Noreturn \ && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) # if defined _MSC_VER && 1200 <= _MSC_VER # define _Noreturn __declspec (noreturn) # else # define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) #else # define YYUSE(E) /* empty */ #endif #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value #endif #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif #ifndef YY_INITIAL_VALUE # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* 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 # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's 'empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; }; /* 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 (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 /* 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_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ while (0) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 1166 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 98 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 86 /* YYNRULES -- Number of rules. */ #define YYNRULES 198 /* YYNSTATES -- Number of states. */ #define YYNSTATES 337 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 327 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 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, 84, 2, 2, 2, 78, 66, 2, 93, 94, 77, 75, 95, 76, 91, 79, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 60, 92, 71, 59, 69, 61, 87, 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, 88, 2, 89, 65, 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, 96, 64, 97, 85, 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, 51, 52, 53, 54, 55, 56, 57, 58, 62, 63, 67, 68, 70, 72, 73, 74, 80, 81, 82, 83, 86, 90 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 208, 208, 220, 208, 287, 289, 288, 321, 322, 324, 326, 331, 333, 338, 339, 343, 390, 417, 426, 434, 447, 455, 446, 495, 497, 511, 520, 521, 522, 523, 524, 527, 528, 531, 532, 535, 547, 548, 551, 552, 555, 556, 557, 558, 559, 560, 561, 576, 577, 580, 581, 584, 589, 588, 609, 608, 625, 633, 641, 652, 652, 654, 655, 658, 664, 673, 680, 689, 691, 690, 695, 699, 700, 701, 702, 703, 704, 705, 706, 710, 711, 716, 726, 735, 740, 745, 739, 761, 765, 760, 779, 783, 790, 778, 806, 807, 811, 815, 810, 856, 858, 863, 872, 862, 889, 888, 906, 907, 913, 922, 933, 940, 939, 951, 950, 964, 970, 963, 982, 993, 1004, 1008, 1014, 1019, 1020, 1036, 1038, 1040, 1039, 1051, 1061, 1071, 1070, 1084, 1083, 1096, 1102, 1108, 1114, 1120, 1126, 1132, 1138, 1144, 1150, 1156, 1163, 1180, 1188, 1195, 1202, 1209, 1210, 1215, 1221, 1236, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1251, 1256, 1263, 1264, 1265, 1269, 1275, 1282, 1293, 1298, 1304, 1310, 1316, 1322, 1344, 1370, 1393, 1410, 1420, 1426, 1425, 1524, 1535, 1541, 1552, 1554, 1568, 1579, 1587, 1584, 1598, 1605 }; #endif #if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "TOK_STATIC", "TOK_PRIVATE", "TOK_TYPE", "TOK_CLASS", "TOK_SELF", "TOK_ARRAY", "TOK_OBJECT", "TOK_STRING_DECL", "TOK_REALT", "TOK_INT", "TOK_NUMBER", "TOK_STRING", "TOK_REAL", "TOK_SWITCH", "TOK_CASE", "TOK_DEFAULT", "TOK_IDENTIFIER", "TOK_TYNAME", "TOK_NEW", "TOK_VOID", "TOK_INHERIT", "TOK_COLON_COLON", "TOK_ENUM", "TOK_AS", "TOK_IMPORT", "TOK_END", "TOK_MODULE", "TOK_CATCH", "TOK_THROW", "TOK_GENERIC", "TOK_ABSTRACT", "TOK_DOTDOT", "TOK_LEFT_ARR", "TOK_RIGHT_ARR", "TOK_IF", "TOK_THEN", "TOK_ELSE", "TOK_WHILE", "TOK_DO", "TOK_FOR", "TOK_BREAK", "TOK_CONTINUE", "TOK_RETURN", "TOK_CONST", "TOK_LSH_EQ", "TOK_RSH_EQ", "TOK_LARROW", "TOK_AND_EQ", "TOK_OR_EQ", "TOK_XOR_EQ", "TOK_ADD_EQ", "TOK_SUB_EQ", "TOK_MULT_EQ", "TOK_DIV_EQ", "TOK_MOD_EQ", "OPASSIGN", "'='", "':'", "'?'", "TOK_LOR", "TOK_LAND", "'|'", "'^'", "'&'", "TOK_EQ", "TOK_NE", "'>'", "TOK_GE", "'<'", "TOK_LE", "TOK_LSH", "TOK_RSH", "'+'", "'-'", "'*'", "'%'", "'/'", "POSTINC", "POSTDEC", "TOK_INC", "TOK_DEC", "'!'", "'~'", "UMINUS", "'@'", "'['", "']'", "TOK_ARROW", "'.'", "';'", "'('", "')'", "','", "'{'", "'}'", "$accept", "all", "$@1", "$@2", "program", "$@3", "in_options", "import_list", "inheritance_list", "inheritance", "import", "number", "realnumber", "function_def", "@4", "@5", "statprivtype", "static", "arglist", "fun_arglist", "new_fun_arg", "possible_type", "type", "basetype", "typelist", "global_name_list", "new_global_name_decl", "@6", "@7", "new_global_name", "block", "blktmp", "local_declaration", "$@8", "local_list", "locid_decl", "newlocid", "statements", "$@9", "simple_stmt", "statement", "while", "@10", "@11", "do", "@12", "$@13", "for", "@14", "@15", "$@16", "for_expr", "switch", "@17", "@18", "switch_expr", "switch_case", "@19", "$@20", "@21", "comma_expr", "prefix", "stmt_expr", "$@22", "@23", "@24", "@25", "expr", "$@26", "@27", "@28", "op_assign", "return", "expr_list", "constant_expr", "constant_expr2", "variable", "string", "bracket_list", "function_call", "@29", "function_name", "ifstmt", "@30", "if_expr", "identifier", YY_NULLPTR }; #endif # ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 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, 306, 307, 308, 309, 310, 311, 312, 313, 61, 58, 63, 314, 315, 124, 94, 38, 316, 317, 62, 318, 60, 319, 320, 321, 43, 45, 42, 37, 47, 322, 323, 324, 325, 33, 126, 326, 64, 91, 93, 327, 46, 59, 40, 41, 44, 123, 125 }; # endif #define YYPACT_NINF -274 #define yypact_value_is_default(Yystate) \ (!!((Yystate) == (-274))) #define YYTABLE_NINF -192 #define yytable_value_is_error(Yytable_value) \ (!!((Yytable_value) == (-192))) /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int16 yypact[] = { -274, 15, 20, -274, 58, 13, -274, 30, 20, -274, -274, 41, 68, 68, -274, -274, 30, -274, -274, -274, 61, 62, 161, -274, -274, 22, 158, 179, 68, -274, 68, 43, -274, -274, 105, -274, -21, -274, -54, 98, 68, -274, -274, -274, -274, -274, -274, 200, -274, -274, -274, 127, -274, 68, -274, -274, -274, -274, -274, -57, -274, -274, -274, 25, 100, -274, -274, 553, 553, 2, 200, -274, -274, -274, -274, -274, 171, -274, 68, 68, -274, 553, 553, 553, 553, 553, 553, 454, -274, -274, -274, -274, 915, -274, 333, -274, -274, -274, 103, 915, -39, 104, -274, 109, 68, -274, 68, -274, -274, 421, 90, 90, 90, 90, 90, -5, 553, -64, 915, -274, -274, -274, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 106, 477, -10, 68, 553, -274, -274, 346, 107, -274, 553, -274, 43, -274, -274, -274, 553, 114, -274, -274, 120, 122, 123, 553, 67, -274, -274, -274, -274, -274, -274, -274, -274, -274, -274, 821, 124, -274, -274, 1, -274, 553, 553, 553, 553, 999, 1025, 1050, 1075, 1075, 96, 96, 96, 96, 211, 211, 216, 216, 90, 90, 90, 553, -274, 586, 553, 107, -274, 915, -274, -274, -274, -274, -274, -274, -274, -274, -274, -274, 553, 553, -274, 915, 121, -274, 125, 40, 553, 421, 131, 421, 553, -274, -274, 128, 329, 68, -274, -274, 134, 915, 915, 944, 972, 540, 553, 505, -274, 617, -274, 915, 32, -274, 553, -274, 651, 186, 553, -274, 137, 128, 138, 135, -274, 141, 139, -40, -274, -274, 176, 145, 853, -274, 884, 107, -274, 685, -274, -274, 719, 198, -274, -274, -274, 236, -274, 68, 553, 553, 553, 68, -274, -274, -274, -274, 421, -274, 146, 553, -274, -274, 915, 35, 915, 147, 160, -274, 421, 553, 149, -274, 553, 130, -274, 753, -274, 787, -274, 183, 18, -274, 167, 553, -274, 175, -274, -274, -274, -274, 170, -274, 205, 236, -274, -274, -274, 421, 236, -274, -274 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 2, 0, 8, 1, 0, 0, 3, 9, 10, 14, 12, 0, 0, 0, 5, 13, 11, 15, 16, 198, 0, 0, 6, 18, 17, 28, 27, 29, 0, 7, 0, 37, 30, 31, 0, 57, 0, 50, 52, 57, 0, 43, 45, 42, 44, 41, 46, 0, 26, 38, 39, 0, 24, 0, 55, 53, 21, 47, 48, 0, 176, 175, 178, 0, 0, 180, 51, 0, 169, 32, 0, 40, 177, 179, 25, 19, 184, 20, 0, 0, 114, 0, 0, 0, 0, 0, 169, 0, 173, 174, 152, 156, 56, 127, 124, 172, 121, 186, 181, 170, 0, 0, 33, 34, 0, 49, 0, 125, 193, 0, 155, 109, 110, 153, 154, 0, 169, 0, 107, 116, 132, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 119, 120, 0, 0, 54, 0, 22, 37, 36, 192, 97, 0, 0, 85, 88, 0, 0, 0, 167, 0, 59, 60, 79, 84, 80, 115, 73, 75, 74, 76, 0, 0, 72, 122, 0, 126, 0, 0, 0, 0, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 0, 128, 0, 0, 0, 183, 111, 160, 161, 157, 158, 159, 162, 163, 164, 166, 165, 0, 169, 187, 171, 0, 35, 0, 0, 0, 0, 0, 0, 95, 82, 83, 168, 0, 0, 78, 77, 0, 108, 117, 133, 135, 0, 0, 0, 182, 0, 188, 113, 0, 23, 0, 81, 0, 194, 0, 89, 0, 96, 0, 0, 69, 0, 62, 64, 67, 123, 0, 0, 0, 130, 0, 0, 185, 0, 197, 195, 0, 0, 91, 71, 58, 0, 61, 0, 0, 169, 0, 0, 129, 131, 189, 98, 0, 86, 0, 95, 70, 63, 66, 0, 118, 0, 0, 196, 0, 0, 0, 65, 0, 0, 87, 0, 92, 0, 102, 0, 0, 100, 0, 95, 190, 0, 105, 99, 101, 90, 0, 184, 0, 0, 93, 103, 106, 0, 0, 94, 104 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -274, -274, -274, -274, -274, -274, -274, 260, -274, 261, 16, -274, -274, -274, -274, -274, -274, -274, -274, 133, -274, 239, -27, -41, -274, -274, 221, -274, -274, 256, 71, -274, -274, -274, 9, -274, -274, -212, -274, -274, -107, -274, -274, -274, -274, -274, -274, -274, -274, -274, -274, -273, -274, -274, -274, -274, -19, -274, -274, -274, -17, -274, -274, -274, -274, -274, -274, -23, -274, -274, -274, -274, -274, -83, -16, -274, -274, -274, -186, -274, -274, -274, -274, -274, -274, -12 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 1, 2, 14, 22, 25, 6, 7, 8, 9, 10, 88, 89, 29, 69, 220, 30, 31, 101, 102, 103, 104, 164, 50, 59, 36, 37, 68, 67, 38, 165, 232, 166, 233, 261, 262, 263, 259, 281, 167, 260, 169, 226, 304, 170, 227, 277, 171, 295, 319, 333, 256, 172, 222, 302, 316, 317, 321, 334, 329, 257, 90, 91, 145, 109, 180, 266, 173, 242, 181, 182, 216, 174, 100, 93, 64, 94, 95, 218, 96, 146, 97, 175, 292, 225, 98 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { 20, 21, 168, 115, 49, 54, 58, 70, 40, 19, 41, 42, 43, 44, 45, 3, 35, 246, 39, 284, 12, -37, 306, 15, 46, 26, 27, 13, 57, 105, 178, 179, 15, 177, 55, 314, 315, 71, 72, 65, 73, 35, 49, 4, 92, 99, 326, 5, 285, 40, 147, 41, 42, 43, 44, 45, 148, 5, 110, 111, 112, 113, 114, 99, 118, 46, 107, 108, 28, 296, 117, 52, 11, 40, 53, 41, 42, 43, 44, 45, 75, 76, 77, 202, 176, 290, 19, 19, 78, 46, 148, 79, 151, 99, 152, 47, 148, 80, 236, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 323, 201, 332, 253, 205, 255, 58, 336, 49, 307, 219, 272, 148, 203, 204, 148, 118, 251, 18, 248, 179, 47, 223, 118, 118, 60, 61, 62, 81, 231, 117, 19, 314, 315, 82, 83, 84, 85, 23, 24, 86, 237, 238, 239, 240, 87, -4, 32, 116, 51, -192, -192, -192, -192, 131, 132, 133, 134, 135, 136, 137, 241, 138, 139, 245, 140, 141, 33, 138, 139, 303, 140, 141, 75, 327, 77, 56, 74, 247, 99, 106, -191, 310, 149, 199, 217, 252, 299, 63, 150, 118, 40, 224, 41, 42, 43, 44, 45, 228, 229, 230, 235, 163, 250, 268, 270, 264, 46, 179, 254, 275, 335, 273, 265, 278, 279, 276, 280, 282, 283, 287, 286, 258, 294, 305, 308, 312, 40, 322, 41, 42, 43, 44, 45, 75, 76, 77, 153, -68, -68, 19, 309, 78, 46, 325, 79, 298, 99, 300, 330, 331, 80, 154, 16, 17, 48, 264, 118, 155, 66, 301, 156, 157, 158, 159, 160, 161, 311, 221, 34, 313, 133, 134, 135, 136, 137, 249, 297, 135, 136, 137, 118, 324, 138, 139, 0, 140, 141, 138, 139, 328, 140, 141, 0, 0, 0, 0, 81, 0, 0, 0, 0, 0, 82, 83, 84, 85, 0, 0, 86, 0, 0, 0, 0, 162, 258, 0, 163, -68, 0, 40, 0, 41, 42, 43, 44, 45, 75, 76, 77, 153, 0, 0, 19, 0, 78, 46, 0, 79, 0, 0, 0, 0, 0, 80, 154, 0, 0, 0, 0, 0, 155, 0, 0, 156, 157, 158, 159, 160, 161, 0, 0, 0, 0, 0, -112, -112, 0, -112, -112, -112, -112, -112, -112, -112, -112, 0, 142, 206, 207, 0, 208, 209, 210, 211, 212, 213, 214, 215, 0, 81, 0, 0, 0, 0, 0, 82, 83, 84, 85, 143, 144, 86, 0, 0, 0, 0, 162, 0, 0, 163, -68, 40, 0, 41, 42, 43, 44, 45, 75, 76, 77, 153, 0, 0, 19, 0, 78, 46, 0, 79, 0, 0, 0, 0, 0, 80, 154, 0, 0, 0, 0, 0, 155, 0, 0, 156, 157, 158, 159, 160, 161, 75, 76, 77, 0, 0, 0, 19, 0, 78, 0, 0, 79, 0, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 75, 76, 77, 0, 0, 0, 19, 81, 78, 0, 0, 79, 0, 82, 83, 84, 85, 80, 0, 86, 0, 200, 0, 0, 162, 0, 0, 163, 75, 76, 77, 0, 0, 0, 19, 0, 78, 0, 0, 79, 81, 0, 0, 0, 0, 80, 82, 83, 84, 85, 0, 0, 86, 0, 0, 0, 0, 87, 0, 0, 116, 0, 0, 81, 0, 0, 0, 0, 0, 82, 83, 84, 85, 0, 0, 86, 75, 76, 77, 0, 87, 0, 19, 0, 78, 0, 0, 79, 0, 0, 0, 81, 0, 80, 0, 0, 0, 82, 83, 84, 85, 0, 0, 86, 269, 0, 0, 0, 87, 0, 0, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 243, 0, 0, 0, 0, 0, 0, 138, 139, 81, 140, 141, 0, 0, 267, 82, 83, 84, 85, 0, 0, 86, 0, 0, 0, 0, 87, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 244, 140, 141, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 0, 0, 271, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 0, 0, 274, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 0, 0, 291, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 0, 0, 293, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 0, 0, 318, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 0, 0, 320, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 234, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 288, 140, 141, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 289, 140, 141, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141, -192, -192, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 138, 139, 0, 140, 141 }; static const yytype_int16 yycheck[] = { 12, 13, 109, 86, 31, 59, 47, 64, 6, 19, 8, 9, 10, 11, 12, 0, 28, 203, 30, 59, 7, 19, 295, 7, 22, 3, 4, 14, 40, 70, 94, 95, 16, 116, 88, 17, 18, 94, 13, 51, 15, 53, 69, 23, 67, 68, 319, 27, 88, 6, 89, 8, 9, 10, 11, 12, 95, 27, 81, 82, 83, 84, 85, 86, 87, 22, 78, 79, 46, 281, 87, 92, 14, 6, 95, 8, 9, 10, 11, 12, 13, 14, 15, 93, 89, 271, 19, 19, 21, 22, 95, 24, 104, 116, 106, 93, 95, 30, 97, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 97, 139, 329, 225, 142, 227, 162, 334, 150, 89, 148, 94, 95, 140, 141, 95, 154, 92, 92, 217, 95, 93, 154, 161, 162, 13, 14, 15, 76, 161, 162, 19, 17, 18, 82, 83, 84, 85, 92, 92, 88, 179, 180, 181, 182, 93, 0, 4, 96, 59, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 199, 87, 88, 202, 90, 91, 3, 87, 88, 292, 90, 91, 13, 14, 15, 93, 92, 216, 217, 24, 93, 304, 94, 93, 93, 224, 285, 76, 95, 228, 6, 93, 8, 9, 10, 11, 12, 93, 92, 92, 92, 96, 93, 242, 243, 233, 22, 95, 93, 39, 333, 250, 94, 92, 92, 254, 97, 92, 95, 90, 60, 1, 40, 93, 93, 92, 6, 60, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 96, 21, 22, 92, 24, 284, 285, 286, 94, 60, 30, 31, 8, 8, 31, 283, 295, 37, 53, 287, 40, 41, 42, 43, 44, 45, 305, 150, 28, 308, 75, 76, 77, 78, 79, 220, 283, 77, 78, 79, 319, 316, 87, 88, -1, 90, 91, 87, 88, 321, 90, 91, -1, -1, -1, -1, 76, -1, -1, -1, -1, -1, 82, 83, 84, 85, -1, -1, 88, -1, -1, -1, -1, 93, 1, -1, 96, 97, -1, 6, -1, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, -1, 19, -1, 21, 22, -1, 24, -1, -1, -1, -1, -1, 30, 31, -1, -1, -1, -1, -1, 37, -1, -1, 40, 41, 42, 43, 44, 45, -1, -1, -1, -1, -1, 47, 48, -1, 50, 51, 52, 53, 54, 55, 56, 57, -1, 59, 47, 48, -1, 50, 51, 52, 53, 54, 55, 56, 57, -1, 76, -1, -1, -1, -1, -1, 82, 83, 84, 85, 82, 83, 88, -1, -1, -1, -1, 93, -1, -1, 96, 97, 6, -1, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, -1, 19, -1, 21, 22, -1, 24, -1, -1, -1, -1, -1, 30, 31, -1, -1, -1, -1, -1, 37, -1, -1, 40, 41, 42, 43, 44, 45, 13, 14, 15, -1, -1, -1, 19, -1, 21, -1, -1, 24, -1, -1, -1, -1, -1, 30, -1, -1, -1, -1, -1, 13, 14, 15, -1, -1, -1, 19, 76, 21, -1, -1, 24, -1, 82, 83, 84, 85, 30, -1, 88, -1, 34, -1, -1, 93, -1, -1, 96, 13, 14, 15, -1, -1, -1, 19, -1, 21, -1, -1, 24, 76, -1, -1, -1, -1, 30, 82, 83, 84, 85, -1, -1, 88, -1, -1, -1, -1, 93, -1, -1, 96, -1, -1, 76, -1, -1, -1, -1, -1, 82, 83, 84, 85, -1, -1, 88, 13, 14, 15, -1, 93, -1, 19, -1, 21, -1, -1, 24, -1, -1, -1, 76, -1, 30, -1, -1, -1, 82, 83, 84, 85, -1, -1, 88, 89, -1, -1, -1, 93, -1, -1, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 34, -1, -1, -1, -1, -1, -1, 87, 88, 76, 90, 91, -1, -1, 94, 82, 83, 84, 85, -1, -1, 88, -1, -1, -1, -1, 93, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, 89, 90, 91, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, -1, -1, 94, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, -1, -1, 94, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, -1, -1, 94, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, -1, -1, 94, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, -1, -1, 94, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, -1, -1, 94, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, 92, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, 89, 90, 91, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, 89, 90, 91, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, -1, -1, -1, -1, -1, -1, -1, 87, 88, -1, 90, 91 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 99, 100, 0, 23, 27, 104, 105, 106, 107, 108, 14, 7, 14, 101, 108, 105, 107, 92, 19, 183, 183, 102, 92, 92, 103, 3, 4, 46, 111, 114, 115, 4, 3, 127, 183, 123, 124, 127, 183, 6, 8, 9, 10, 11, 12, 22, 93, 119, 120, 121, 59, 92, 95, 59, 88, 93, 183, 121, 122, 13, 14, 15, 76, 173, 183, 124, 126, 125, 112, 64, 94, 13, 15, 92, 13, 14, 15, 21, 24, 30, 76, 82, 83, 84, 85, 88, 93, 109, 110, 159, 160, 165, 172, 174, 175, 177, 179, 183, 165, 171, 116, 117, 118, 119, 121, 24, 183, 183, 162, 165, 165, 165, 165, 165, 171, 96, 158, 165, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 87, 88, 90, 91, 59, 82, 83, 161, 178, 89, 95, 94, 95, 183, 183, 16, 31, 37, 40, 41, 42, 43, 44, 45, 93, 96, 120, 128, 130, 137, 138, 139, 142, 145, 150, 165, 170, 180, 89, 171, 94, 95, 163, 167, 168, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 93, 34, 165, 93, 183, 183, 165, 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 169, 93, 176, 165, 113, 117, 151, 158, 93, 182, 140, 143, 93, 92, 92, 158, 129, 131, 92, 92, 97, 165, 165, 165, 165, 165, 166, 34, 89, 165, 176, 165, 171, 128, 93, 92, 165, 138, 93, 138, 149, 158, 1, 135, 138, 132, 133, 134, 183, 94, 164, 94, 165, 89, 165, 94, 94, 165, 94, 39, 165, 144, 92, 92, 97, 136, 92, 95, 59, 88, 60, 90, 89, 89, 176, 94, 181, 94, 40, 146, 135, 132, 165, 171, 165, 183, 152, 138, 141, 93, 149, 89, 93, 96, 138, 165, 92, 165, 17, 18, 153, 154, 94, 147, 94, 155, 60, 97, 154, 92, 149, 14, 172, 157, 94, 60, 135, 148, 156, 138, 135 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 98, 100, 101, 99, 102, 103, 102, 104, 104, 104, 104, 105, 105, 106, 106, 107, 108, 108, 109, 110, 112, 113, 111, 111, 111, 114, 115, 115, 115, 115, 115, 116, 116, 117, 117, 118, 119, 119, 120, 120, 121, 121, 121, 121, 121, 121, 121, 122, 122, 123, 123, 124, 125, 124, 126, 124, 127, 128, 129, 131, 130, 132, 132, 133, 133, 133, 134, 135, 136, 135, 135, 137, 137, 137, 137, 137, 137, 137, 137, 138, 138, 138, 138, 138, 140, 141, 139, 143, 144, 142, 146, 147, 148, 145, 149, 149, 151, 152, 150, 153, 153, 155, 156, 154, 157, 154, 158, 158, 159, 159, 160, 161, 160, 162, 160, 163, 164, 160, 160, 160, 160, 165, 165, 165, 165, 165, 165, 166, 165, 165, 165, 167, 165, 168, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 170, 170, 171, 171, 171, 172, 172, 172, 173, 173, 173, 173, 173, 173, 174, 174, 174, 175, 176, 178, 177, 177, 177, 177, 179, 179, 179, 180, 181, 180, 182, 183 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 0, 0, 4, 0, 0, 3, 0, 1, 1, 2, 1, 2, 1, 2, 3, 4, 4, 1, 1, 0, 0, 8, 3, 5, 2, 1, 0, 1, 2, 2, 0, 1, 1, 3, 2, 0, 1, 1, 3, 1, 1, 1, 1, 1, 1, 2, 1, 3, 1, 3, 1, 0, 5, 0, 4, 1, 4, 0, 0, 4, 1, 3, 1, 4, 3, 1, 0, 0, 3, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 3, 2, 2, 1, 0, 0, 7, 0, 0, 9, 0, 0, 0, 12, 0, 1, 0, 0, 9, 1, 2, 0, 0, 6, 0, 4, 1, 3, 2, 2, 3, 0, 4, 0, 3, 0, 0, 7, 2, 2, 1, 3, 5, 1, 2, 3, 1, 0, 6, 5, 6, 0, 4, 0, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 3, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 4, 3, 1, 3, 0, 3, 4, 6, 10, 1, 3, 2, 3, 0, 6, 3, 1 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY) \ { \ yychar = (Token); \ yylval = (Value); \ YYPOPSTACK (yylen); \ yystate = *yyssp; \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (0) /* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) /* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*----------------------------------------. | Print this symbol's value on YYOUTPUT. | `----------------------------------------*/ static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { FILE *yyo = yyoutput; YYUSE (yyo); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { YYFPRINTF (yyoutput, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], &(yyvsp[(yyi + 1) - (yynrhs)]) ); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyssp, yyvsp, Rule); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T yystrlen (const char *yystr) { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * yystpcpy (char *yydest, const char *yysrc) { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { yyp++; yyformat++; } } return 0; } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) { YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; /*----------. | yyparse. | `----------*/ int yyparse (void) { int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: 'yyss': related to states. 'yyvs': related to semantic values. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yyssp = yyss = yyssa; yyvsp = yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = yylex (); } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: #line 208 "mud.y" /* yacc.c:1646 */ { /* initialise here! */ prog_head = 0; CPD = 0; num_globals = 0; num_constants = 0; global_head = 0; free_type_list(); penultima.s = 0; ultima.s = 0; } #line 1933 "y.tab.c" /* yacc.c:1646 */ break; case 3: #line 220 "mud.y" /* yacc.c:1646 */ { Func *p; /* * should check inherit_file and return if there are some * files to be loaded */ if (inherit_file != NULL) { inherit_file[file_number] = 0; return 0; } if (inherit_ob != NULL) { inherit_ob[inherit_number] = 0; } p = alloc_function(0, shared_string_copy(C("*InitGlobals")), INITIAL_FUNC_SIZE, 0); p->next = 0; p->num_arg = 0; CPD = p; emit(S_ENTER, 0); if (inherit_ob != NULL || inherit_file != NULL) { Shared * v; char pname[1024]; int i; for (i = 0; inherit_ob[i]; i++) { emit(S_PUSH8, 0); emit(S_PUSHCARGS, 0); emit(S_PUSHCOFF, 0); emit(S_ADDSP, 0); strcpy(pname, inherit_ob[i]->name->str); strcat(pname, "::*InitGlobals"); v = string_copy(pname); add_patch(CPD, P_CALLU, v); /* printf("S_CALLU: %s\n", v); */ emit64(S_CALLU, (char *)&(v)); } } initialise_func = p; prog_head = p; init_globals(); CPD = initialise_func; } #line 1983 "y.tab.c" /* yacc.c:1646 */ break; case 4: #line 267 "mud.y" /* yacc.c:1646 */ { initialise_func->next = 0; CPD = initialise_func; /* copy initialise code block to a non-global one */ emit(S_PUSH8, 0); emits(S_RETURN); emits(S_END); CPD->block = code_size_fix(CPD); CPD->num_var = 0; prog_head = (yyvsp[0].lnode); if (!prog_head) { printf("No program returned!\n"); } make_global_tables(); } #line 2004 "y.tab.c" /* yacc.c:1646 */ break; case 5: #line 287 "mud.y" /* yacc.c:1646 */ { (yyval.lnode) = prog_head; /* start of program */ } #line 2010 "y.tab.c" /* yacc.c:1646 */ break; case 6: #line 289 "mud.y" /* yacc.c:1646 */ { block_depth = 0; penultima.s = 0; ultima.s = 0; } #line 2020 "y.tab.c" /* yacc.c:1646 */ break; case 7: #line 295 "mud.y" /* yacc.c:1646 */ { if ((yyvsp[0].lnode) != 0) { Func *p = (Func *)(yyvsp[0].lnode); p->next = (Func *)(yyvsp[-2].lnode); (yyval.lnode) = p; /* should this also check efuns & emulatefuns? */ if (defined_function(p->name->str)) { yyerror("Illegal to redeclare function."); } } else { (yyval.lnode) = (yyvsp[-2].lnode); } } #line 2042 "y.tab.c" /* yacc.c:1646 */ break; case 8: #line 321 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2048 "y.tab.c" /* yacc.c:1646 */ break; case 9: #line 323 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2054 "y.tab.c" /* yacc.c:1646 */ break; case 10: #line 325 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2060 "y.tab.c" /* yacc.c:1646 */ break; case 11: #line 327 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2066 "y.tab.c" /* yacc.c:1646 */ break; case 12: #line 332 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[0].number); } #line 2072 "y.tab.c" /* yacc.c:1646 */ break; case 13: #line 334 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[0].number); } #line 2078 "y.tab.c" /* yacc.c:1646 */ break; case 16: #line 344 "mud.y" /* yacc.c:1646 */ { /* FIX:: MAX_INHERIT is non-dynamic brain damage */ if (inherit_number >= MAX_INHERIT) { free((yyvsp[-1].lexstr)); yyerror("Too many files inherited.\n"); } else { Shared * inhs = to_Cstring((yyvsp[-1].lexstr)); free((yyvsp[-1].lexstr)); if (inherit_ob == NULL) { inherit_ob = (Class **) malloc(sizeof(Class *) * (MAX_INHERIT+1)); inherit_number = 0; } /* External dependency! */ //printf("find class: %s\n", inhs->str); inherit_ob[inherit_number] = find_class(inhs); //if (inherit_ob[inherit_number]) printf("found: (%d) %s\n", // inherit_number, inherit_ob[inherit_number]->name->str); if (inherit_ob[inherit_number] == 0) { if (inherit_file == NULL) { inherit_file = (Shared **) malloc(sizeof(Shared *) * (MAX_INHERIT+1)); file_number = 0; } inherit_file[file_number++] = inhs; inherit_file[file_number] = 0; } else { inherit_number++; free_string(inhs); } } } #line 2126 "y.tab.c" /* yacc.c:1646 */ break; case 17: #line 391 "mud.y" /* yacc.c:1646 */ { Shared * inhs = to_Cstring((yyvsp[-2].lexstr)); Class *iobj; free((yyvsp[-2].lexstr)); /* need to insure stuff is loaded. fuck fuck fuck */ iobj = find_class(inhs); if (!iobj) { /* sigh - nasty piece of work. */ if (!inherit_file) { inherit_file = (Shared **) malloc(sizeof(char *) * (MAX_INHERIT+1)); file_number = 0; } inherit_file[file_number++] = inhs; inherit_file[file_number] = 0; free_string((yyvsp[-1].shared)); } else { add_type_list((yyvsp[-1].shared), iobj); } (yyval.number) = 0; } #line 2156 "y.tab.c" /* yacc.c:1646 */ break; case 18: #line 418 "mud.y" /* yacc.c:1646 */ { /* FIX:: self importing */ add_type_list((yyvsp[-1].shared), 0); (yyval.number) = 0; } #line 2166 "y.tab.c" /* yacc.c:1646 */ break; case 19: #line 427 "mud.y" /* yacc.c:1646 */ { emit_number((yyvsp[0].number)); (yyval.number) = (int)(yyvsp[0].number); } #line 2175 "y.tab.c" /* yacc.c:1646 */ break; case 20: #line 435 "mud.y" /* yacc.c:1646 */ { char * x; (yyval.real) = (yyvsp[0].real); x = (char *)(&(yyval.real)); emit32(S_PUSHr, x); #if 0 printf("real yacc: %f (%x %x %x %x)\n", (yyval.real), x[0], x[1], x[2], x[3]); #endif } #line 2189 "y.tab.c" /* yacc.c:1646 */ break; case 21: #line 447 "mud.y" /* yacc.c:1646 */ { block_depth++; (yyval.lnode) = alloc_function((yyvsp[-2].number), (yyvsp[-1].shared), INITIAL_FUNC_SIZE, 0); CPD = (yyval.lnode); new_function(); } #line 2201 "y.tab.c" /* yacc.c:1646 */ break; case 22: #line 455 "mud.y" /* yacc.c:1646 */ { struct var_def *t = arg_head; /* haven't taken into account ret addr and old bp on stack */ if (arg_head != NULL) { /* emit(S_COPY, num_args); */ while (t) { emit16(S_TYPEC, t->type); /* if (t->type != T_ANY) emit16(S_TYPEC, t->type); else emit(S_ADDSP, -1); */ t = t->next; } } emit(S_ENTER, 0); CPD->num_arg = num_args; (yyval.number) = CPD->current_I; } #line 2228 "y.tab.c" /* yacc.c:1646 */ break; case 23: #line 478 "mud.y" /* yacc.c:1646 */ { Func *p = (yyvsp[-4].lnode); patch8((yyvsp[-1].number) - 1, max_locals); /* p->num_arg = num_args; */ /* p->type = p->type | $1; */ (yyval.lnode) = p; CPD = (yyval.lnode); /* free the local and arg space */ free_locals(); emit(S_PUSH8,0); emits(S_RETURN); emits(S_END); p->block = code_size_fix(p); p->num_var = max_locals; block_depth--; if (block_depth == 0) CPD = initialise_func; } #line 2250 "y.tab.c" /* yacc.c:1646 */ break; case 24: #line 496 "mud.y" /* yacc.c:1646 */ { (yyval.lnode) = 0; } #line 2256 "y.tab.c" /* yacc.c:1646 */ break; case 25: #line 498 "mud.y" /* yacc.c:1646 */ { /* + these could be copy propagated later? */ /* + need to redefine global_table in object */ /* + copy in values when creating variable table */ /* + also must ensure these aren't assigned to! */ add_global_variable((yyvsp[-3].shared), (yyvsp[-1].val)->type | TY_CONSTANT, (yyvsp[-1].val)); (yyval.lnode) = 0; } #line 2270 "y.tab.c" /* yacc.c:1646 */ break; case 26: #line 512 "mud.y" /* yacc.c:1646 */ { /* $$ = $2; 41093 */ current_type = (yyvsp[-1].number) | (yyvsp[0].number); (yyval.number) = current_type; static_variable_flag = (yyval.number); } #line 2281 "y.tab.c" /* yacc.c:1646 */ break; case 27: #line 520 "mud.y" /* yacc.c:1646 */ { (yyval.number) = TY_STATIC; } #line 2287 "y.tab.c" /* yacc.c:1646 */ break; case 28: #line 521 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2293 "y.tab.c" /* yacc.c:1646 */ break; case 29: #line 522 "mud.y" /* yacc.c:1646 */ { (yyval.number) = TY_PRIVATE; } #line 2299 "y.tab.c" /* yacc.c:1646 */ break; case 30: #line 523 "mud.y" /* yacc.c:1646 */ { (yyval.number) = TY_STATIC | TY_PRIVATE; } #line 2305 "y.tab.c" /* yacc.c:1646 */ break; case 31: #line 524 "mud.y" /* yacc.c:1646 */ { (yyval.number) = TY_STATIC | TY_PRIVATE; } #line 2311 "y.tab.c" /* yacc.c:1646 */ break; case 32: #line 527 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2317 "y.tab.c" /* yacc.c:1646 */ break; case 33: #line 528 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[0].number); } #line 2323 "y.tab.c" /* yacc.c:1646 */ break; case 36: #line 536 "mud.y" /* yacc.c:1646 */ { /* only called when processing args */ if (find_argument((yyvsp[0].shared))) yyerrorf("Name \"%s\"appears twice in function parameter list\n", (yyvsp[0].shared)->str); else add_argument((yyvsp[0].shared), current_type); (yyval.number) = 0; } #line 2336 "y.tab.c" /* yacc.c:1646 */ break; case 37: #line 547 "mud.y" /* yacc.c:1646 */ { (yyval.number) = T_ANY; current_type = T_ANY; } #line 2342 "y.tab.c" /* yacc.c:1646 */ break; case 38: #line 548 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[0].number); current_type = (yyvsp[0].number); } #line 2348 "y.tab.c" /* yacc.c:1646 */ break; case 39: #line 551 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[0].number); } #line 2354 "y.tab.c" /* yacc.c:1646 */ break; case 40: #line 552 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[-1].number); } #line 2360 "y.tab.c" /* yacc.c:1646 */ break; case 41: #line 555 "mud.y" /* yacc.c:1646 */ { (yyval.number) = T_NUMBER; } #line 2366 "y.tab.c" /* yacc.c:1646 */ break; case 42: #line 556 "mud.y" /* yacc.c:1646 */ { (yyval.number) = T_STRING; } #line 2372 "y.tab.c" /* yacc.c:1646 */ break; case 43: #line 557 "mud.y" /* yacc.c:1646 */ { (yyval.number) = T_POINTER; } #line 2378 "y.tab.c" /* yacc.c:1646 */ break; case 44: #line 558 "mud.y" /* yacc.c:1646 */ { (yyval.number) = T_REAL; } #line 2384 "y.tab.c" /* yacc.c:1646 */ break; case 45: #line 559 "mud.y" /* yacc.c:1646 */ { (yyval.number) = T_OBJECT; } #line 2390 "y.tab.c" /* yacc.c:1646 */ break; case 46: #line 560 "mud.y" /* yacc.c:1646 */ { (yyval.number) = T_VOID; } #line 2396 "y.tab.c" /* yacc.c:1646 */ break; case 47: #line 562 "mud.y" /* yacc.c:1646 */ { struct field * x; x = find_type((yyvsp[0].shared)); if (x) { (yyval.number) = x->type; free(x); } else (yyval.number) = 0; free_string((yyvsp[0].shared)); } #line 2413 "y.tab.c" /* yacc.c:1646 */ break; case 48: #line 576 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[0].number); } #line 2419 "y.tab.c" /* yacc.c:1646 */ break; case 49: #line 577 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[-2].number) | (yyvsp[0].number); } #line 2425 "y.tab.c" /* yacc.c:1646 */ break; case 50: #line 580 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2431 "y.tab.c" /* yacc.c:1646 */ break; case 51: #line 581 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2437 "y.tab.c" /* yacc.c:1646 */ break; case 52: #line 585 "mud.y" /* yacc.c:1646 */ { add_global_variable((yyvsp[0].shared), current_type, 0); } #line 2445 "y.tab.c" /* yacc.c:1646 */ break; case 53: #line 589 "mud.y" /* yacc.c:1646 */ { (yyval.lnode) = CPD; CPD = initialise_func; } #line 2454 "y.tab.c" /* yacc.c:1646 */ break; case 54: #line 594 "mud.y" /* yacc.c:1646 */ { int x, y; y = current_type | ((yyvsp[-1].number) << 16); #if 0 printf("adding type %d,%d = %d\n", (yyvsp[-1].number), current_type, y); #endif x = add_global_variable((yyvsp[-4].shared), y, 0); emit_number((yyvsp[-1].number)); emits(S_ARR_ALLOC); emit(S_POPG, x-1); type_check((yyvsp[-1].number), T_ANY, T_NUMBER, "array declaration"); CPD = (yyvsp[-2].lnode); } #line 2473 "y.tab.c" /* yacc.c:1646 */ break; case 55: #line 609 "mud.y" /* yacc.c:1646 */ { (yyval.lnode) = CPD; CPD = initialise_func; add_global_variable((yyvsp[-1].shared), current_type, 0); } #line 2483 "y.tab.c" /* yacc.c:1646 */ break; case 56: #line 615 "mud.y" /* yacc.c:1646 */ { int x = find_global_variable((yyvsp[-3].shared)); /* printf("Global no: %d.\n", x); */ emit(S_POPG, x - 1); type_check((yyvsp[0].number), T_ANY, current_type, "global assignment"); CPD = (yyvsp[-1].lnode); } #line 2496 "y.tab.c" /* yacc.c:1646 */ break; case 57: #line 626 "mud.y" /* yacc.c:1646 */ { if (find_global_variable((yyvsp[0].shared))) yyerrorf("Redeclaration of global variable \"%s\"\n", (yyvsp[0].shared)->str); (yyval.shared) = (yyvsp[0].shared); } #line 2506 "y.tab.c" /* yacc.c:1646 */ break; case 58: #line 634 "mud.y" /* yacc.c:1646 */ { block_depth--; num_locals = (yyvsp[-2].number); } #line 2515 "y.tab.c" /* yacc.c:1646 */ break; case 59: #line 641 "mud.y" /* yacc.c:1646 */ { (yyval.number) = num_locals; block_depth++; /* re-set in 'block' */ } #line 2524 "y.tab.c" /* yacc.c:1646 */ break; case 60: #line 652 "mud.y" /* yacc.c:1646 */ { current_type = (yyvsp[0].number); } #line 2530 "y.tab.c" /* yacc.c:1646 */ break; case 61: #line 652 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[-1].number); } #line 2536 "y.tab.c" /* yacc.c:1646 */ break; case 64: #line 659 "mud.y" /* yacc.c:1646 */ { int x = add_local_variable((yyvsp[0].shared), current_type); emit(S_PUSH8, 0); emit(S_POPL, x - 1); } #line 2546 "y.tab.c" /* yacc.c:1646 */ break; case 65: #line 665 "mud.y" /* yacc.c:1646 */ { int x, y; y = current_type | ((yyvsp[-1].number) << 16); x = add_local_variable((yyvsp[-3].shared), y); emit_number((yyvsp[-1].number)); emits(S_ARR_ALLOC); emit(S_POPL, x - 1); } #line 2559 "y.tab.c" /* yacc.c:1646 */ break; case 66: #line 674 "mud.y" /* yacc.c:1646 */ { int x = add_local_variable((yyvsp[-2].shared), current_type); emit(S_POPL, x - 1); } #line 2568 "y.tab.c" /* yacc.c:1646 */ break; case 67: #line 681 "mud.y" /* yacc.c:1646 */ { if (find_local_block((yyvsp[0].shared))) yyerrorf("Redefinition of \"%s\" within the same block", (yyvsp[0].shared)->str); (yyval.shared) = (yyvsp[0].shared); } #line 2578 "y.tab.c" /* yacc.c:1646 */ break; case 68: #line 689 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2584 "y.tab.c" /* yacc.c:1646 */ break; case 69: #line 691 "mud.y" /* yacc.c:1646 */ { end_of_statement(); } #line 2592 "y.tab.c" /* yacc.c:1646 */ break; case 71: #line 695 "mud.y" /* yacc.c:1646 */ { yyerror("Illegal statement"); (yyval.number) = 0; } #line 2598 "y.tab.c" /* yacc.c:1646 */ break; case 76: #line 703 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2604 "y.tab.c" /* yacc.c:1646 */ break; case 77: #line 704 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2610 "y.tab.c" /* yacc.c:1646 */ break; case 78: #line 705 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2616 "y.tab.c" /* yacc.c:1646 */ break; case 79: #line 706 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2622 "y.tab.c" /* yacc.c:1646 */ break; case 81: #line 712 "mud.y" /* yacc.c:1646 */ { emits(S_THROW); (yyval.number) = 0; } #line 2631 "y.tab.c" /* yacc.c:1646 */ break; case 82: #line 717 "mud.y" /* yacc.c:1646 */ { if ((LD == 0) && (switch_depth == 0)) { yyerror("Break outside while, for, do, or switch construct.\n"); } add_break_patch(CPD->current_I); emit16(S_JUMPU, 0); (yyval.number) = 0; } #line 2645 "y.tab.c" /* yacc.c:1646 */ break; case 83: #line 727 "mud.y" /* yacc.c:1646 */ { if (LD == 0) { yyerror("Continue outside while, for, or do loop.\n"); } emit16(S_JUMP, labelstack[LD-1] - CPD->current_I - 3); (yyval.number) = 0; } #line 2658 "y.tab.c" /* yacc.c:1646 */ break; case 84: #line 735 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2664 "y.tab.c" /* yacc.c:1646 */ break; case 85: #line 740 "mud.y" /* yacc.c:1646 */ { labelstack[LD++] = CPD->current_I; (yyval.number) = CPD->current_I; } #line 2673 "y.tab.c" /* yacc.c:1646 */ break; case 86: #line 745 "mud.y" /* yacc.c:1646 */ { emit16(S_JZERO,0); (yyval.number) = CPD->current_I; } #line 2682 "y.tab.c" /* yacc.c:1646 */ break; case 87: #line 750 "mud.y" /* yacc.c:1646 */ { end_of_statement(); emits(S_OFLOW_CHECK); emit16(S_JUMP, (yyvsp[-5].number) - CPD->current_I - 3); patch16((int)(yyvsp[-1].number) - 2, CPD->current_I - (yyvsp[-1].number)); do_break_patch((yyvsp[-5].number), CPD->current_I); LD--; } #line 2695 "y.tab.c" /* yacc.c:1646 */ break; case 88: #line 761 "mud.y" /* yacc.c:1646 */ { (yyval.number) = CPD->current_I; labelstack[LD++] = CPD->current_I; } #line 2704 "y.tab.c" /* yacc.c:1646 */ break; case 89: #line 765 "mud.y" /* yacc.c:1646 */ { end_of_statement(); } #line 2712 "y.tab.c" /* yacc.c:1646 */ break; case 90: #line 770 "mud.y" /* yacc.c:1646 */ { emits(S_OFLOW_CHECK); emit16(S_JNZERO, (yyvsp[-7].number) - CPD->current_I - 3); do_break_patch((yyvsp[-7].number), CPD->current_I); LD--; } #line 2723 "y.tab.c" /* yacc.c:1646 */ break; case 91: #line 779 "mud.y" /* yacc.c:1646 */ { (yyval.number) = CPD->current_I; } #line 2731 "y.tab.c" /* yacc.c:1646 */ break; case 92: #line 783 "mud.y" /* yacc.c:1646 */ { emit16(S_JZERO, 0); emit16(S_JUMP, 0); (yyval.number) = CPD->current_I; labelstack[LD++] = CPD->current_I; } #line 2742 "y.tab.c" /* yacc.c:1646 */ break; case 93: #line 790 "mud.y" /* yacc.c:1646 */ { emit16(S_JUMP, (yyvsp[-5].number) - CPD->current_I - 3); patch16((int)((yyvsp[-2].number) - 2), CPD->current_I - (yyvsp[-2].number)); } #line 2751 "y.tab.c" /* yacc.c:1646 */ break; case 94: #line 795 "mud.y" /* yacc.c:1646 */ { end_of_statement(); emits(S_OFLOW_CHECK); emit16(S_JUMP, (yyvsp[-4].number) - CPD->current_I - 3); patch16((int)((yyvsp[-4].number) - 5), CPD->current_I - (yyvsp[-4].number) + 3); do_break_patch((yyvsp[-7].number), CPD->current_I); LD--; } #line 2764 "y.tab.c" /* yacc.c:1646 */ break; case 95: #line 806 "mud.y" /* yacc.c:1646 */ { emit(S_PUSH8, 1); } #line 2770 "y.tab.c" /* yacc.c:1646 */ break; case 97: #line 811 "mud.y" /* yacc.c:1646 */ { (yyval.number) = CPD->current_I; } #line 2778 "y.tab.c" /* yacc.c:1646 */ break; case 98: #line 815 "mud.y" /* yacc.c:1646 */ { int x; /* add a global *switch[X] */ /* this will be an array ({ const, line num, const etc }) */ x = add_global_variable(make_next_switch(),TY_STATIC|T_ANY,0); emit(S_SWITCH, x - 1); /* switch on global */ switchstack[switch_depth++] = CPD->current_I; /* set up the constants */ (yyval.lnode) = CPD; CPD = initialise_func; emit_push(GLOBAL, x); CPD = (yyval.lnode); (yyval.lnode) = x; } #line 2798 "y.tab.c" /* yacc.c:1646 */ break; case 99: #line 831 "mud.y" /* yacc.c:1646 */ { int x = (yyvsp[-1].number), y; /* once we've emitted all the statements emit switch table */ (yyval.lnode) = CPD; y = CPD->current_I - switchstack[switch_depth-1]; CPD = initialise_func; x = x * 2 + 2; /* we don't need to emit this IF we emitted a default: case */ emit(S_PUSH8, -2); /* no match marker.. */ emit_number(y); assert(x >= 0); emit16(S_AGGREGATE,x); emits(S_POPO); CPD = (yyval.lnode); (yyval.lnode) = 0; switch_depth--; do_break_patch((yyvsp[-7].number), CPD->current_I); } #line 2826 "y.tab.c" /* yacc.c:1646 */ break; case 100: #line 857 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 1; } #line 2832 "y.tab.c" /* yacc.c:1646 */ break; case 101: #line 859 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[-1].number) + 1; } #line 2838 "y.tab.c" /* yacc.c:1646 */ break; case 102: #line 863 "mud.y" /* yacc.c:1646 */ { #if 1 /* record the last line */ (yyval.lnode) = CPD; CPD = initialise_func; #endif } #line 2850 "y.tab.c" /* yacc.c:1646 */ break; case 103: #line 872 "mud.y" /* yacc.c:1646 */ { #if 1 int x; /* put the offset line number (next for code) */ CPD = (yyvsp[-2].lnode); x = CPD->current_I - switchstack[switch_depth-1]; CPD = initialise_func; emit_number(x); CPD = (yyvsp[-2].lnode); #endif } #line 2866 "y.tab.c" /* yacc.c:1646 */ break; case 104: #line 884 "mud.y" /* yacc.c:1646 */ { /* return line number? */ (yyval.lnode) = 0; } #line 2875 "y.tab.c" /* yacc.c:1646 */ break; case 105: #line 889 "mud.y" /* yacc.c:1646 */ { /* two defaults should generate an error; it doesn't yet */ int y; (yyval.lnode) = CPD; y = -(CPD->current_I-switchstack[switch_depth-1]) - 1; /* number is negative so we recognise it! */ CPD = initialise_func; emit(S_PUSH8, -1); emit_number(y); CPD = (yyval.lnode); } #line 2891 "y.tab.c" /* yacc.c:1646 */ break; case 106: #line 901 "mud.y" /* yacc.c:1646 */ { (yyval.lnode) = 0; } #line 2899 "y.tab.c" /* yacc.c:1646 */ break; case 108: #line 908 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[0].number); } #line 2907 "y.tab.c" /* yacc.c:1646 */ break; case 109: #line 914 "mud.y" /* yacc.c:1646 */ { emit(S_COPY, 1); emit(S_PUSH8, 1); emits(S_PLUS); emit_pop((yyvsp[0].number)); type_check((yyvsp[0].number), T_ANY, T_NUMBER, "pre ++"); (yyval.number) = (yyvsp[0].number); } #line 2920 "y.tab.c" /* yacc.c:1646 */ break; case 110: #line 923 "mud.y" /* yacc.c:1646 */ { emit(S_COPY, 1); emit(S_PUSH8, -1); emits(S_PLUS); emit_pop((yyvsp[0].number)); type_check((yyvsp[0].number), T_ANY, T_NUMBER, "pre --"); (yyval.number) = (yyvsp[0].number); } #line 2933 "y.tab.c" /* yacc.c:1646 */ break; case 111: #line 934 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_ANY, "variable assignment"); (yyval.number) = (yyvsp[-2].number); emit_pop((yyvsp[-2].number)); } #line 2943 "y.tab.c" /* yacc.c:1646 */ break; case 112: #line 940 "mud.y" /* yacc.c:1646 */ { emit(S_COPY, 1); } #line 2951 "y.tab.c" /* yacc.c:1646 */ break; case 113: #line 944 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-3].number), (yyvsp[0].number), T_ANY, "variable op= assignment"); (yyval.number) = (yyvsp[-3].number); emits((yyvsp[-1].number)); emit_pop((yyvsp[-3].number)); } #line 2962 "y.tab.c" /* yacc.c:1646 */ break; case 114: #line 951 "mud.y" /* yacc.c:1646 */ { emit16(S_CATCH, 0); (yyval.number) = CPD->current_I; } #line 2971 "y.tab.c" /* yacc.c:1646 */ break; case 115: #line 956 "mud.y" /* yacc.c:1646 */ { end_of_statement(); /* back patch the correct line */ emits(S_POPCATCH); patch16((yyvsp[-1].number) - 2, CPD->current_I - (yyvsp[-1].number)); (yyval.number) = T_ANY; } #line 2983 "y.tab.c" /* yacc.c:1646 */ break; case 116: #line 964 "mud.y" /* yacc.c:1646 */ { emit16(S_JZERO, 0); (yyval.number) = CPD->current_I; /* $$ is just after jmp offset */ } #line 2993 "y.tab.c" /* yacc.c:1646 */ break; case 117: #line 970 "mud.y" /* yacc.c:1646 */ { emit16(S_JUMP, 0); (yyval.number) = CPD->current_I; patch16((int)(yyvsp[-1].number) - 2, CPD->current_I - (yyvsp[-1].number)); } #line 3004 "y.tab.c" /* yacc.c:1646 */ break; case 118: #line 977 "mud.y" /* yacc.c:1646 */ { patch16((int)(yyvsp[-2].number) - 2, CPD->current_I - (yyvsp[-2].number)); type_check((yyvsp[-3].number), (yyvsp[0].number), T_ANY, "conditional operator"); (yyval.number) = (yyvsp[-3].number); } #line 3014 "y.tab.c" /* yacc.c:1646 */ break; case 119: #line 983 "mud.y" /* yacc.c:1646 */ { emit(S_COPY, 1); emit(S_PUSH8, 1); emits(S_PLUS); emit_pop((yyvsp[-1].number)); emit(S_PUSH8, 1); emits(S_MINUS); type_check((yyvsp[-1].number), T_ANY, T_NUMBER, "post inc"); (yyval.number) = (yyvsp[-1].number); } #line 3029 "y.tab.c" /* yacc.c:1646 */ break; case 120: #line 994 "mud.y" /* yacc.c:1646 */ { emit(S_COPY, 1); emit(S_PUSH8, 1); emits(S_MINUS); emit_pop((yyvsp[-1].number)); emit(S_PUSH8, 1); emits(S_PLUS); type_check((yyvsp[-1].number), T_ANY, T_NUMBER, "post dec"); (yyval.number) = (yyvsp[-1].number); } #line 3044 "y.tab.c" /* yacc.c:1646 */ break; case 121: #line 1004 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[0].number); } #line 3050 "y.tab.c" /* yacc.c:1646 */ break; case 122: #line 1009 "mud.y" /* yacc.c:1646 */ { emit16(S_AGGREGATE, (short) (yyvsp[-1].number)); (yyval.number) = T_POINTER; } #line 3059 "y.tab.c" /* yacc.c:1646 */ break; case 123: #line 1015 "mud.y" /* yacc.c:1646 */ { emit16(S_AGGREGATE, (short) (yyvsp[-2].number)); (yyval.number) = T_POINTER; } #line 3068 "y.tab.c" /* yacc.c:1646 */ break; case 124: #line 1019 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[0].number); } #line 3074 "y.tab.c" /* yacc.c:1646 */ break; case 125: #line 1021 "mud.y" /* yacc.c:1646 */ { struct field * x; x = find_type((yyvsp[0].shared)); if (x) { emit(S_PUSH8, x->offset); emit(S_PUSH8, 1); emits(S_ARR_ALLOC); (yyval.number) = x->type; free(x); } free_string((yyvsp[0].shared)); } #line 3094 "y.tab.c" /* yacc.c:1646 */ break; case 126: #line 1037 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[-1].number); } #line 3100 "y.tab.c" /* yacc.c:1646 */ break; case 128: #line 1040 "mud.y" /* yacc.c:1646 */ { emit(S_PUSH8, 0); } #line 3108 "y.tab.c" /* yacc.c:1646 */ break; case 129: #line 1044 "mud.y" /* yacc.c:1646 */ { /* emits(S_EXTRACT); */ emit(S_EFUND, F_EXTRACT); type_check((yyvsp[-5].number), T_ANY, T_POINTER|T_STRING, "extract arg 1"); type_check((yyvsp[-1].number), T_ANY, T_NUMBER, "extract arg 3"); (yyval.number) = (yyvsp[-5].number); } #line 3120 "y.tab.c" /* yacc.c:1646 */ break; case 130: #line 1052 "mud.y" /* yacc.c:1646 */ { int x = INT_MAX; emit32(S_PUSHi, (char *)&x); /* emits(S_EXTRACT); */ emit(S_EFUND, F_EXTRACT); type_check((yyvsp[-4].number), T_ANY, T_POINTER|T_STRING, "extract arg 1"); type_check((yyvsp[-2].number), T_ANY, T_NUMBER, "extract arg 2"); (yyval.number) = (yyvsp[-4].number); } #line 3134 "y.tab.c" /* yacc.c:1646 */ break; case 131: #line 1062 "mud.y" /* yacc.c:1646 */ { /* emits(S_EXTRACT); */ emit(S_EFUND, F_EXTRACT); type_check((yyvsp[-5].number), T_ANY, T_POINTER|T_STRING, "extract arg 1"); type_check((yyvsp[-3].number), T_ANY, T_NUMBER, "extract arg 2"); type_check((yyvsp[-1].number), T_ANY, T_NUMBER, "extract arg 3"); (yyval.number) = (yyvsp[-5].number); } #line 3147 "y.tab.c" /* yacc.c:1646 */ break; case 132: #line 1071 "mud.y" /* yacc.c:1646 */ { emit(S_COPY, 1); emit16(S_JNZERO, 0); (yyval.number) = CPD->current_I; } #line 3157 "y.tab.c" /* yacc.c:1646 */ break; case 133: #line 1077 "mud.y" /* yacc.c:1646 */ { /* type_check($1, $4, T_ANY); */ (yyval.number) = T_NUMBER; emits(S_LOR); patch16((yyvsp[-1].number) -2, CPD->current_I - (yyvsp[-1].number)); } #line 3168 "y.tab.c" /* yacc.c:1646 */ break; case 134: #line 1084 "mud.y" /* yacc.c:1646 */ { emit(S_COPY, 1); emit16(S_JZERO, 0); (yyval.number) = CPD->current_I; } #line 3178 "y.tab.c" /* yacc.c:1646 */ break; case 135: #line 1090 "mud.y" /* yacc.c:1646 */ { /* type_check($1, $4, T_ANY); */ (yyval.number) = T_NUMBER; emits(S_LAND); patch16((yyvsp[-1].number) -2, CPD->current_I - (yyvsp[-1].number)); } #line 3189 "y.tab.c" /* yacc.c:1646 */ break; case 136: #line 1097 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_NUMBER, "arithmetic or"); (yyval.number) = (yyvsp[-2].number); emits(S_OR); } #line 3199 "y.tab.c" /* yacc.c:1646 */ break; case 137: #line 1103 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_NUMBER, "arithmetic xor"); (yyval.number) = (yyvsp[-2].number); emits(S_XOR); } #line 3209 "y.tab.c" /* yacc.c:1646 */ break; case 138: #line 1109 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_NUMBER, "arithmetic and"); (yyval.number) = (yyvsp[-2].number); emits(S_AND); } #line 3219 "y.tab.c" /* yacc.c:1646 */ break; case 139: #line 1115 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_ANY, "equals"); (yyval.number) = T_NUMBER; emits(S_EQ); } #line 3229 "y.tab.c" /* yacc.c:1646 */ break; case 140: #line 1121 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_ANY, "not equals"); (yyval.number) = T_NUMBER; emits(S_NE); } #line 3239 "y.tab.c" /* yacc.c:1646 */ break; case 141: #line 1127 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_STRING|T_REAL|T_NUMBER, ">"); (yyval.number) = T_NUMBER; emits(S_GT); } #line 3249 "y.tab.c" /* yacc.c:1646 */ break; case 142: #line 1133 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_STRING|T_REAL|T_NUMBER, ">="); (yyval.number) = T_NUMBER; emits(S_GE); } #line 3259 "y.tab.c" /* yacc.c:1646 */ break; case 143: #line 1139 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_STRING|T_REAL|T_NUMBER, "<"); (yyval.number) = T_NUMBER; emits(S_LT); } #line 3269 "y.tab.c" /* yacc.c:1646 */ break; case 144: #line 1145 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_STRING|T_REAL|T_NUMBER, "<="); (yyval.number) = T_NUMBER; emits(S_LE); } #line 3279 "y.tab.c" /* yacc.c:1646 */ break; case 145: #line 1151 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_NUMBER, "lsh"); (yyval.number) = T_NUMBER; emits(S_LSH); } #line 3289 "y.tab.c" /* yacc.c:1646 */ break; case 146: #line 1157 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[-2].number), (yyvsp[0].number), T_NUMBER, "rsh"); (yyval.number) = T_NUMBER; emits(S_RSH); } #line 3299 "y.tab.c" /* yacc.c:1646 */ break; case 147: #line 1164 "mud.y" /* yacc.c:1646 */ { /* const fix hack should do constant check on last 2 pushes, if both strings or numbers then add them remove 2 instrs and add the new push */ if (!constant_fold(S_PLUS)) { emits(S_PLUS); type_check((yyvsp[-2].number),T_ANY,T_REAL|T_NUMBER|T_STRING|T_POINTER, "plus"); type_check((yyvsp[0].number),T_ANY,T_REAL|T_NUMBER|T_STRING|T_POINTER, "plus"); if (((yyvsp[-2].number) & T_POINTER) || ((yyvsp[0].number) & T_POINTER)) { if (!((yyvsp[-2].number) & (yyvsp[0].number))) yyerror("Illegal array addition\n"); } (yyval.number) = ((yyvsp[-2].number) > (yyvsp[0].number)) ? (yyvsp[-2].number) : (yyvsp[0].number); } } #line 3320 "y.tab.c" /* yacc.c:1646 */ break; case 148: #line 1181 "mud.y" /* yacc.c:1646 */ { if (!constant_fold(S_MINUS)) { emits(S_MINUS); type_check((yyvsp[-2].number), (yyvsp[0].number), T_REAL|T_NUMBER, "minus"); (yyval.number) = (yyvsp[-2].number); } } #line 3332 "y.tab.c" /* yacc.c:1646 */ break; case 149: #line 1189 "mud.y" /* yacc.c:1646 */ { /* if (!constant_fold(S_MULT)) */ emits(S_MULT); type_check((yyvsp[-2].number), (yyvsp[0].number), T_REAL|T_NUMBER, "multiply"); (yyval.number) = (yyvsp[-2].number); } #line 3343 "y.tab.c" /* yacc.c:1646 */ break; case 150: #line 1196 "mud.y" /* yacc.c:1646 */ { /* if (!constant_fold(S_MOD)) */ emits(S_MOD); type_check((yyvsp[-2].number), (yyvsp[0].number), T_NUMBER, "modulo"); (yyval.number) = (yyvsp[-2].number); } #line 3354 "y.tab.c" /* yacc.c:1646 */ break; case 151: #line 1203 "mud.y" /* yacc.c:1646 */ { /* if (!constant_fold(S_DIVIDE)) */ emits(S_DIVIDE); type_check((yyvsp[-2].number), (yyvsp[0].number), T_REAL|T_NUMBER, "divide"); (yyval.number) = (yyvsp[-2].number); } #line 3365 "y.tab.c" /* yacc.c:1646 */ break; case 153: #line 1211 "mud.y" /* yacc.c:1646 */ { emits(S_LNOT); (yyval.number) = T_NUMBER; } #line 3374 "y.tab.c" /* yacc.c:1646 */ break; case 154: #line 1216 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[0].number), T_ANY, T_NUMBER, "arithmetic not"); (yyval.number) = T_NUMBER; emits(S_NOT); } #line 3384 "y.tab.c" /* yacc.c:1646 */ break; case 155: #line 1222 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[0].number), T_ANY, T_NUMBER | T_REAL, "negate"); (yyval.number) = (yyvsp[0].number); #if 1 if (uinstr == S_PUSH8) { char x; x = -(CPD->block[CPD->current_I-1]); CPD->block[CPD->current_I-1] = x; } /* should also do PUSHi & PUSHr */ else #endif emits(S_NEGATE); } #line 3403 "y.tab.c" /* yacc.c:1646 */ break; case 157: #line 1239 "mud.y" /* yacc.c:1646 */ { (yyval.number) = S_AND; } #line 3409 "y.tab.c" /* yacc.c:1646 */ break; case 158: #line 1240 "mud.y" /* yacc.c:1646 */ { (yyval.number) = S_OR; } #line 3415 "y.tab.c" /* yacc.c:1646 */ break; case 159: #line 1241 "mud.y" /* yacc.c:1646 */ { (yyval.number) = S_XOR; } #line 3421 "y.tab.c" /* yacc.c:1646 */ break; case 160: #line 1242 "mud.y" /* yacc.c:1646 */ { (yyval.number) = S_LSH; } #line 3427 "y.tab.c" /* yacc.c:1646 */ break; case 161: #line 1243 "mud.y" /* yacc.c:1646 */ { (yyval.number) = S_RSH; } #line 3433 "y.tab.c" /* yacc.c:1646 */ break; case 162: #line 1244 "mud.y" /* yacc.c:1646 */ { (yyval.number) = S_PLUS; } #line 3439 "y.tab.c" /* yacc.c:1646 */ break; case 163: #line 1245 "mud.y" /* yacc.c:1646 */ { (yyval.number) = S_MINUS; } #line 3445 "y.tab.c" /* yacc.c:1646 */ break; case 164: #line 1246 "mud.y" /* yacc.c:1646 */ { (yyval.number) = S_MULT; } #line 3451 "y.tab.c" /* yacc.c:1646 */ break; case 165: #line 1247 "mud.y" /* yacc.c:1646 */ { (yyval.number) = S_MOD; } #line 3457 "y.tab.c" /* yacc.c:1646 */ break; case 166: #line 1248 "mud.y" /* yacc.c:1646 */ { (yyval.number) = S_DIVIDE; } #line 3463 "y.tab.c" /* yacc.c:1646 */ break; case 167: #line 1252 "mud.y" /* yacc.c:1646 */ { emit(S_PUSH8, 0); emits(S_RETURN); } #line 3472 "y.tab.c" /* yacc.c:1646 */ break; case 168: #line 1257 "mud.y" /* yacc.c:1646 */ { type_check((yyvsp[0].number), T_ANY, CPD->type, "return type of function"); emits(S_RETURN); } #line 3481 "y.tab.c" /* yacc.c:1646 */ break; case 169: #line 1263 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 3487 "y.tab.c" /* yacc.c:1646 */ break; case 170: #line 1264 "mud.y" /* yacc.c:1646 */ { (yyval.number) = 1; } #line 3493 "y.tab.c" /* yacc.c:1646 */ break; case 171: #line 1265 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[-2].number) + 1; } #line 3499 "y.tab.c" /* yacc.c:1646 */ break; case 172: #line 1270 "mud.y" /* yacc.c:1646 */ { penultima.s = ultima.s; ultima.s = (yyvsp[0].lexstr); (yyval.number) = T_STRING; } #line 3509 "y.tab.c" /* yacc.c:1646 */ break; case 173: #line 1276 "mud.y" /* yacc.c:1646 */ { penultima.i = ultima.i; ultima.i = (yyvsp[0].number); if (!((yyvsp[0].number))) (yyval.number) = T_ANY; /* zero hack :( */ else (yyval.number) = T_NUMBER; } #line 3520 "y.tab.c" /* yacc.c:1646 */ break; case 174: #line 1283 "mud.y" /* yacc.c:1646 */ { /* penultima.r = ultima.r; ultima.r = $1; $$ = $1; */ (yyval.number) = T_REAL; } #line 3533 "y.tab.c" /* yacc.c:1646 */ break; case 175: #line 1294 "mud.y" /* yacc.c:1646 */ { (yyval.val) = share_Cstring(to_Cstring((yyvsp[0].lexstr))); free((yyvsp[0].lexstr)); } #line 3542 "y.tab.c" /* yacc.c:1646 */ break; case 176: #line 1299 "mud.y" /* yacc.c:1646 */ { (yyval.val) = alloc_value(); (yyval.val)->type = T_NUMBER; (yyval.val)->u.number = (yyvsp[0].number); } #line 3552 "y.tab.c" /* yacc.c:1646 */ break; case 177: #line 1305 "mud.y" /* yacc.c:1646 */ { (yyval.val) = alloc_value(); (yyval.val)->type = T_NUMBER; (yyval.val)->u.number = - (yyvsp[0].number); } #line 3562 "y.tab.c" /* yacc.c:1646 */ break; case 178: #line 1311 "mud.y" /* yacc.c:1646 */ { (yyval.val) = alloc_value(); (yyval.val)->type = T_REAL; (yyval.val)->u.number = (yyvsp[0].number); } #line 3572 "y.tab.c" /* yacc.c:1646 */ break; case 179: #line 1317 "mud.y" /* yacc.c:1646 */ { (yyval.val) = alloc_value(); (yyval.val)->type = T_REAL; (yyval.val)->u.number = - (yyvsp[0].number); } #line 3582 "y.tab.c" /* yacc.c:1646 */ break; case 180: #line 1323 "mud.y" /* yacc.c:1646 */ { Val * x; if ((x = find_constant((yyvsp[0].shared)))) { /* printf("Global no: %d.\n", $$); */ (yyval.val) = alloc_value(); // FIX: look up global assign_value((yyval.val), x); } else { yyerror("Only constant values maybe used in switch expressions\n"); } free_string((yyvsp[0].shared)); } #line 3603 "y.tab.c" /* yacc.c:1646 */ break; case 181: #line 1345 "mud.y" /* yacc.c:1646 */ { int x; Val * v; if ((x = find_local_variable((yyvsp[0].shared)))) { emit_push(LOCAL, x-1); } else if ((x = find_argument((yyvsp[0].shared)))) { emit_push(LOCAL, x); } else if ((x = find_global_variable((yyvsp[0].shared)))) { emit_push(GLOBAL, x); /* printf("Global no: %d.\n", $$); */ } else if ((v = find_constant((yyvsp[0].shared)))) { /* what should we do? */ emit_constant(v); } else yyerrorf("Identifier %s used but not declared", (yyvsp[0].shared)->str); free_string((yyvsp[0].shared)); (yyval.number) = last_type; } #line 3633 "y.tab.c" /* yacc.c:1646 */ break; case 182: #line 1371 "mud.y" /* yacc.c:1646 */ { int t, r; /* ADDIND should typecheck too! */ emits(S_ADDIND); (yyval.number) = 0; type_check((yyvsp[-1].number), T_ANY, T_NUMBER, "array access arg 2"); t = ((yyvsp[-3].number) & 0x00ff0000) >> 16; if (!t) { if ((yyvsp[-3].number) & 0xff000000) yyerror("Non class accessed\n"); else { (yyval.number) = T_ANY; type_check((yyvsp[-3].number),T_ANY,T_POINTER|T_STRING, "array access arg 1"); } } else { r = (yyvsp[-3].number) & 0xff00ffff; t--; (yyval.number) = (t << 16) | r; } } #line 3660 "y.tab.c" /* yacc.c:1646 */ break; case 183: #line 1394 "mud.y" /* yacc.c:1646 */ { struct field * x; x = find_type_info((yyvsp[-2].number), (yyvsp[0].shared)); if (x) { emit(S_PUSH8, x->offset); emits(S_ADDIND); type_check((yyvsp[-2].number), T_ANY, T_POINTER, "class access arg 1"); (yyval.number) = x->type; free(x); } else (yyval.number) = 0; free_string((yyvsp[0].shared)); } #line 3678 "y.tab.c" /* yacc.c:1646 */ break; case 184: #line 1411 "mud.y" /* yacc.c:1646 */ { /* blech */ add_patch(CPD, P_STRING, (yyvsp[0].lexstr)); emit64(S_PUSHs, zero); /* $$ = (lexstr *)p; */ (yyval.lexstr) = (yyvsp[0].lexstr); } #line 3689 "y.tab.c" /* yacc.c:1646 */ break; case 185: #line 1421 "mud.y" /* yacc.c:1646 */ { (yyval.number) = (yyvsp[-1].number); } #line 3695 "y.tab.c" /* yacc.c:1646 */ break; case 186: #line 1426 "mud.y" /* yacc.c:1646 */ { struct keyword * x = 0; x = lookup_emulate((yyvsp[0].shared)); if (!x) x = lookup_predef((yyvsp[0].shared)->str); if (x && (x->token == F_EMULATE)) { Shared * v; /* make it a call_other to Emulate.. */ /* argh need a S_PUSHo opcode now.. */ v = string_copy(EMULATE_EFUN); /* add_patch(CPD, P_CSTRING, v); */ emit64(S_PUSHs, (char *) &(v)); // v = shared_string_copy($1); /* add_patch(CPD, P_CSTRING, v); */ // emit32(S_PUSHs, (char *) &(v)); } else if (!x || (x && (x->token != F_CALL_OTHER))) { emit(S_PUSH8, 0); /* dummy this_object() */ } (yyval.lnode) = x; } #line 3725 "y.tab.c" /* yacc.c:1646 */ break; case 187: #line 1452 "mud.y" /* yacc.c:1646 */ { struct keyword * x; int p, n; x = (struct keyword *)(yyvsp[-1].string); if (x) { // check the no. of parameters is correct */ p = x->params; if (p > 0) { n = (yyvsp[0].number); while (n < p) { emit(S_PUSH8, 0); n++; } if (n > p) { emit(S_ADDSP, n - p); } } emit(S_PUSHCARGS, (yyvsp[0].number)); if (x->token == F_CALL_OTHER) { /* special case for call_other efun() */ byte n = (yyvsp[0].number) - 2; /* patch no of args to be correct */ if ((yyvsp[0].number) < 2) { yyerror("Not enough args to call_other()"); } /* adjust number of params */ CPD->block[CPD->current_I-1] = n; emits(S_CALLOF); } else if (x->token == F_EMULATE) { Shared * ss = shared_string_copy((yyvsp[-2].shared)); /* string should be added to patch list */ /* add_patch(CPD, P_CSTRING, x); */ emit64(S_CALLO, (char *)&(ss)); free(x); } else { //emit(S_PUSHCARGS, $3); /* no of params */ emit(S_EFUN, (char)x->token); } } else { /* It's a local function call. */ Shared * v; emit(S_PUSHCARGS, (yyvsp[0].number)); emit(S_PUSHCOFF, 0); emit(S_ADDSP, 0); /* varargs fix - blech */ v = shared_string_copy((yyvsp[-2].shared)); add_patch(CPD, P_CALLU, v); emit64(S_CALLU, (char *)&(v)); } /* * check function calls later * should be able to do this without * checking the function list again */ free_string((yyvsp[-2].shared)); (yyval.number) = T_ANY; } #line 3802 "y.tab.c" /* yacc.c:1646 */ break; case 188: #line 1525 "mud.y" /* yacc.c:1646 */ { Shared * x = shared_string_copy((yyvsp[-1].shared)); emit(S_PUSHCARGS, (yyvsp[0].number)); /* string should be added to patch list */ /* add_patch(CPD, P_CSTRING, x); */ emit64(S_CALLO, (char *)&(x)); free_string((yyvsp[-1].shared)); (yyval.number) = T_ANY; } #line 3817 "y.tab.c" /* yacc.c:1646 */ break; case 189: #line 1536 "mud.y" /* yacc.c:1646 */ { emit(S_PUSHCARGS, (yyvsp[0].number)); emits(S_CALLOF); (yyval.number) = T_ANY; } #line 3827 "y.tab.c" /* yacc.c:1646 */ break; case 190: #line 1542 "mud.y" /* yacc.c:1646 */ { /* an expr_list in the brackets would be nice.. */ /* need to re-order stack so that $1 is on top */ /* also identifier probably needs to be on the stack */ /* emits(S_CALL_OUT); */ emit(S_EFUND, F_NCALL_OUT); (yyval.number) = T_ANY; } #line 3840 "y.tab.c" /* yacc.c:1646 */ break; case 191: #line 1553 "mud.y" /* yacc.c:1646 */ { (yyval.shared) = (yyvsp[0].shared); } #line 3846 "y.tab.c" /* yacc.c:1646 */ break; case 192: #line 1555 "mud.y" /* yacc.c:1646 */ { /* are the following space leaks? (or fuck up counts anyway?) */ /* perhaps all should use string_copy and we should free elsewhere. */ Shared *t = to_Cstring((yyvsp[-2].lexstr)); char *p = (char *)malloc((yyvsp[0].shared)->length + t->length + 3); strcpy(p, t->str); strcat(p, "::"); strcat(p, (yyvsp[0].shared)->str); (yyval.shared) = string_copy(p); free_string(t); free((yyvsp[-2].lexstr)); free_string((yyvsp[0].shared)); free(p); } #line 3864 "y.tab.c" /* yacc.c:1646 */ break; case 193: #line 1569 "mud.y" /* yacc.c:1646 */ { char *p = (char *)malloc((yyvsp[0].shared)->length + 3); strcpy(p, "::"); strcat(p, (yyvsp[0].shared)->str); (yyval.shared) = string_copy(p); free_string((yyvsp[0].shared)); free(p); } #line 3877 "y.tab.c" /* yacc.c:1646 */ break; case 194: #line 1581 "mud.y" /* yacc.c:1646 */ { patch16((int)(yyvsp[-1].number) - 2, CPD->current_I - (yyvsp[-1].number)); } #line 3885 "y.tab.c" /* yacc.c:1646 */ break; case 195: #line 1587 "mud.y" /* yacc.c:1646 */ { emit16(S_JUMP, 0); patch16((int)(yyvsp[-2].number) - 2, CPD->current_I - (yyvsp[-2].number)); (yyval.number) = CPD->current_I; } #line 3895 "y.tab.c" /* yacc.c:1646 */ break; case 196: #line 1593 "mud.y" /* yacc.c:1646 */ { patch16((int)(yyvsp[-1].number) - 2, CPD->current_I - (yyvsp[-1].number)); } #line 3903 "y.tab.c" /* yacc.c:1646 */ break; case 197: #line 1599 "mud.y" /* yacc.c:1646 */ { emit16(S_JZERO, 0); (yyval.number) = CPD->current_I; } #line 3912 "y.tab.c" /* yacc.c:1646 */ break; case 198: #line 1606 "mud.y" /* yacc.c:1646 */ { (yyval.shared) = string_copy((yyvsp[0].string)); } #line 3920 "y.tab.c" /* yacc.c:1646 */ break; #line 3924 "y.tab.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*--------------------------------------. | yyerrlab -- here on detecting error. | `--------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); } /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif return yyresult; } #line 1610 "mud.y" /* yacc.c:1906 */ int defined_function(char *s) { Func *p; for(p = prog_head; p; p = p->next) { if (strcmp(p->name->str, s) == 0) return 1; } return 0; } /* * All the code below here is * Copyright (C), Geoff Wong, June 1993. * geoff@serc.rmit.edu.au */ int inherited_globals = 0; void init_globals() { int i; inherited_globals = 0; #if 1 if (inherit_ob == NULL) return; for (i = 0; inherit_ob[i]; i++) { inherited_globals += inherit_ob[i]->num_variables; } #endif } /* tail insertion */ int add_global_variable(Shared * s, int type, Val * val) { struct var_def *t; if (lang_debug) printf("D: add global %s\n", s->str); t = (struct var_def *)malloc(sizeof(struct var_def)); t->name = s; if (!type) type = 1; t->type = type; t->next = 0; t->v = val; if (!global_head) { global_tail = t; global_head = t; } else { global_tail->next = t; global_tail = t; } if (type & TY_CONSTANT) { num_constants++; } else num_globals++; return num_globals + inherited_globals; } int find_global_variable(Shared * s) { struct var_def *t = global_head; int d = 0, i, j, count = 1; while (t) { if ((t->type & TY_CONSTANT) == 0) { d++; if (t->name == s) { /* printf("find_global %s\n", t->name); */ last_type = t->type & 0xffff00ff; /* get rid of static */ return d + inherited_globals; } } t = t->next; } #if 1 /* if we want to access inherited vars directly */ if (!inherit_ob) return 0; /* all globals are copied into each level of the object */ for (i = 0; inherit_ob[i]; i++) { for (j = 0; j < inherit_ob[i]->num_variables; j++) { if (inherit_ob[i]->global_table[j]->u.string == s) { last_type = inherit_ob[i]->global_table[j]->type; return count; } count++; } } #endif return 0; } Val * find_constant(Shared * s) { struct var_def *t = global_head; Val * v; while (t) { if ((t->name == s) && (t->type & TY_CONSTANT)) { /* printf("find_constant %s\n", t->name); */ last_type = t->type & 0xffff00ff; /* get rid of static (const etc) */ return t->v; } t = t->next; } if (!inherit_ob) return 0; /* have to recurse into the objects */ v = find_const2(inherit_ob, s); return v; } Val * find_const2(Class ** io, Shared * s) { int i, j; Val * v; for (i = 0; io[i]; i++) { for (j = 0; j < io[i]->num_constants; j++) { if (io[i]->constant_table[j]->name == s) { last_type = io[i]->constant_table[j]->type; return io[i]->constant_table[j]->val; } } if (io[i]->inherit) { v = find_const2(io[i]->inherit, s); if (v) return v; } } return 0; } void make_global_tables() { struct var_def *t = global_head, *x; int d = 0, ct = 0; Val **table = 0; CVal ** consttable = 0; #if 0 printf("%s : num = %d\n", current_file, num_globals); #endif if (!num_globals) table = 0; else table = (Val **) malloc(sizeof(Val *) * (num_globals + 1)); if (!num_constants) consttable = 0; else consttable = (CVal **) malloc(sizeof(CVal *) * (num_constants + 1)); while (t && (d < num_globals || ct < num_constants)) { if (t->type & TY_CONSTANT) { consttable[ct++] = make_const(t->name, t->v, t->type); } else { table[d++] = share_Cstring(t->name); table[d-1]->type = t->type; } x = t; t = t->next; free(x); } global_table = table; constant_table = consttable; return; } /* arguments name stuff */ /* head insertion */ int find_argument(Shared *s) { int d; struct var_def *t = arg_head; d = 0; while (t && d < num_args) { d++; if (t->name == s) { last_type = t->type; return -d; } t = t->next; } return 0; } int add_argument(Shared *s, int type) { struct var_def *t; if (lang_debug) printf("D: add argument %s (%d)\n", s->str, type); t = (struct var_def *)malloc(sizeof(struct var_def)); t->name = s; t->v = 0; t->next = arg_head; t->type = type; arg_head = t; num_args++; return num_args; } /* head insertion for locals. */ int add_local_variable(Shared *s, int type) { struct var_def *t; if (lang_debug) printf("D: add local %s\n", s->str); t = (struct var_def *)malloc(sizeof(struct var_def)); t->name = s; t->next = local_head; t->v = 0; t->type = type; local_head = t; num_locals++; max_locals++; num_block_locals[block_depth]++; return max_locals; } int find_local_variable(Shared *s) { struct var_def *t; int d = max_locals; t = local_head; #if 0 while (t && d > num_locals) { d--; t = t->next; } #endif while (t && d > 0) { if (t->name == s) { /* printf("find_local %s\n", t->name); */ last_type = t->type; return d; } t = t->next; d--; } return 0; } int find_local_block(Shared *s) { struct var_def *t; int d = max_locals, i = 0; t = local_head; while (t && d > num_locals) { d--; t = t->next; } while (t && i < num_block_locals[block_depth]) { i++; d--; if (t->name == s) return d; t = t->next; } return 0; } void free_locals() { struct var_def *x, *t = local_head; while (t) { x = t; t = t->next; free(x); } t = arg_head; while (t) { x = t; t = t->next; free(x); } local_head = 0; arg_head = 0; } int constant_fold(int type) { int size = 10, flag = 0, r; if (type == S_PLUS) { if (puinstr == S_PUSHs && uinstr == S_PUSHs) { #if 0 return 0; printf("constant fold %s + %s\n", penultima.s, ultima.s; #endif /* should this ever happen?? */ if (!penultima.s || !ultima.s) return 0; lex_strcat(penultima.s, ultima.s); /* nuke off folded instructions */ CPD->current_I = CPD->current_I - (sizeof(Shared *)*2 + 2); /* need to nuke off last 2 from patch list */ remove_patch(CPD); remove_patch(CPD); #if 0 Patch *old; old = ((Patch *)CPD->patch); CPD->patch = (char **)((Patch *)CPD->patch)->next->next; CPD->num_str = CPD->num_str - 2; free(old->next); free(old); #endif add_patch(CPD, P_STRING, penultima.s); emit64(S_PUSHs, zero); ultima.s = penultima.s; penultima.s = 0; return 1; } } return 0; if ( (puinstr == S_PUSHi && uinstr == S_PUSH8) || (puinstr == S_PUSH8 && uinstr == S_PUSHi) ) { size = 7; flag = 1; } if (puinstr == S_PUSH8 && uinstr == S_PUSH8) { size = 4; flag = 1; } if (flag || (puinstr == S_PUSHi && uinstr == S_PUSHi)) { switch(type) { case S_PLUS: r = ultima.i + penultima.i; #if 0 printf("constant fold %d + %d in %s\n", penultima.i, ultima.i, current_file); #endif break; case S_MULT: r = penultima.i * ultima.i; break; case S_DIVIDE: r = penultima.i / ultima.i; break; case S_MOD: r = penultima.i % ultima.i; break; case S_MINUS: r = penultima.i - ultima.i; default: break; } CPD->current_I = CPD->current_I - (short)size; if (r <= MAXFIXEDINT && r >= MINFIXEDINT) { emit(S_PUSH8, r); } else { emit32(S_PUSHi, (char *)&r); } puinstr = 0; ultima.i = r; penultima.i = 0; return 1; } #if 0 if (CPD->block[p-11] == S_PUSHr && CPD->block[p-6] == S_PUSHr) { switch(type) { case S_PLUS: z = ultima.r + penultima.r; break; case S_MULT: z = ultima.r * penultima.r; break; case S_DIVIDE: z = ultima.r / penultima.r; break; case S_MOD: yyerror("Illegal modulo on type real.\n"); break; case S_MINUS: z = ultima.r - penultima.r; break; default: break; } CPD->current_I = CPD->current_I - size; emit32(S_PUSHr, (char *)&z); return 1; } #endif return 0; } int type_check(int a, int b, int c, char * where) { return 1; /* FIX: ALERT: this isn't correct for pointer offsets and structs */ if (!(a & b)) { yyerrorf("Types don't match in %s\n", where); #if 0 fprintf(stderr,"NM on a "); print_type(a); fprintf(stderr,"NM on b "); print_type(b); #endif return 0; } if (!(a & c)) { #if 0 printf("type expr = %d\n", a); fprintf(stderr,"IT on a "); print_type(a); #endif yyerrorf("Illegal type present in %s\n", where); return 0; } return 1; } void print_type(int x) { switch (x) { case T_NUMBER: fprintf(stderr,"type integer\n"); break; case T_REAL: fprintf(stderr,"type real\n"); break; case T_POINTER: fprintf(stderr,"type pointer\n"); break; case T_OBJECT: fprintf(stderr,"type object\n"); break; case T_ANY: fprintf(stderr,"type any\n"); break; case T_STRING: fprintf(stderr,"type string\n"); break; default: fprintf(stderr,"Unknown type %d\n", x); break; } } typedef struct TL { Shared * name; Class * obj; } Type_list; #define MAX_CLASSES 16 /* I know - small to start with but hey this many unloaded classes would fuck up! */ Type_list * type_list[MAX_CLASSES]; void add_type_list(Shared * name, Class * object) { Type_list * tmp; // FIX: space leak .. these never get freed tmp = (Type_list *) malloc (sizeof(Type_list)); tmp->name = name; tmp->obj = object; type_list[no_of_classes] = tmp; no_of_classes++; } void free_type_list() { int i; for (i = 0; i < no_of_classes; i++) { if (type_list[i]) free_string(type_list[i]->name); free(type_list[i]); type_list[i] = 0; } no_of_classes = 0; } /* we overload struct field (blech!) using offset for the size we want and */ struct field * find_type(Shared * name) { struct field * tmp; int i; #if 0 printf("find_type\n"); #endif for (i = 0; i < no_of_classes; i++) { if (type_list[i]->name == name) { tmp = (struct field *)malloc(sizeof(struct field)); tmp->offset = type_list[i]->obj->num_variables; tmp->type = ((i+1) << 24) | T_POINTER; return tmp; } } yyerrorf("No such class: %s imported.\n", name->str); return 0; } /* returns a struct of "offset" and type of offset */ struct field * find_type_info(unsigned int typestuff, Shared * fieldname) { unsigned int classnum; struct field * tmp; Class * tobj; int i; if (typestuff & 0x00ff0000) { yyerror("Type error accessing an array as a class.\n"); return 0; } classnum = ((typestuff & 0xff000000) >> 24) -1 ; if (classnum >= no_of_classes) { yyerror("Failed to resolve class type correctly.\n"); return 0; } tmp = (struct field *)malloc(sizeof(struct field)); #if 0 printf("find_type_info %d.\n", classnum); #endif tobj = type_list[classnum]->obj; /* printf("find_type_info: %s.\n", tobj->name); */ for (i = 0; i < (int)tobj->num_variables; i++) { #if 0 printf("type info: %s\n", tobj->global_table[i]->u.string); #endif if (tobj->global_table[i]->u.string == fieldname) { tmp->offset = i; tmp->type = tobj->global_table[i]->type & 0xff; return tmp; } } yyerrorf("Unknown fieldname used in class %s.\n", tobj->name->str); return 0; } /* The emulate file contains emulation functions only at the "top" level (inherited files do not have their functions added to the emulation). (this could be changed using "find_program" - but this has other side effects and is slow compared to 1 hash lookup). Should return 0 if the fun is "::" so we can do direct calls to the driver and ignore the simulated efuns. */ struct keyword * lookup_emulate(Shared * fun) { struct keyword * retval; Func * pr = 0; if (!Emulate) return NULL; pr = Hfunction(fun, Emulate->name); if (!pr) return 0; retval = (struct keyword *) malloc(sizeof(struct keyword)); retval->word = pr->name; retval->token = (short)F_EMULATE; retval->params = -1; return retval; } void end_of_statement() { if (uinstr == S_POPI) { CPD->block[CPD->current_I-1] = S_POPO; uinstr = S_POPI; } }