Annotation of parser3/src/main/compile.tab.C, revision 1.163
1.163 ! moko 1: /* A Bison parser, made by GNU Bison 3.0.2. */
1.112 paf 2:
1.158 misha 3: /* Bison implementation for Yacc-like parsers in C
1.163 ! moko 4:
! 5: Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
! 6:
1.156 moko 7: This program is free software: you can redistribute it and/or modify
1.112 paf 8: it under the terms of the GNU General Public License as published by
1.156 moko 9: the Free Software Foundation, either version 3 of the License, or
10: (at your option) any later version.
1.163 ! moko 11:
1.112 paf 12: This program is distributed in the hope that it will be useful,
13: but WITHOUT ANY WARRANTY; without even the implied warranty of
14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: GNU General Public License for more details.
1.163 ! moko 16:
1.156 moko 17: You should have received a copy of the GNU General Public License
18: along with this program. If not, see <http://www.gnu.org/licenses/>. */
1.155 misha 19:
1.156 moko 20: /* As a special exception, you may create a larger work that contains
21: part or all of the Bison parser skeleton and distribute that work
22: under terms of your choice, so long as that work isn't itself a
23: parser generator using the skeleton or a modified version thereof
24: as a parser skeleton. Alternatively, if you modify or redistribute
25: the parser skeleton itself, you may (at your option) remove this
26: special exception, which will cause the skeleton and the resulting
27: Bison output files to be licensed under the GNU General Public
28: License without this special exception.
1.163 ! moko 29:
1.156 moko 30: This special exception was added by the Free Software Foundation in
31: version 2.2 of Bison. */
1.112 paf 32:
1.156 moko 33: /* C LALR(1) parser skeleton written by Richard Stallman, by
34: simplifying the original so-called "semantic" parser. */
1.112 paf 35:
36: /* All symbols defined below should begin with yy or YY, to avoid
37: infringing on user name space. This should be done even for local
38: variables, as they might otherwise be expanded by user macros.
39: There are some unavoidable exceptions within include files to
40: define necessary library symbols; they are noted "INFRINGES ON
41: USER NAME SPACE" below. */
42:
43: /* Identify Bison output. */
44: #define YYBISON 1
45:
1.156 moko 46: /* Bison version. */
1.163 ! moko 47: #define YYBISON_VERSION "3.0.2"
1.156 moko 48:
1.112 paf 49: /* Skeleton name. */
1.113 paf 50: #define YYSKELETON_NAME "yacc.c"
1.112 paf 51:
52: /* Pure parsers. */
53: #define YYPURE 1
54:
1.156 moko 55: /* Push parsers. */
56: #define YYPUSH 0
57:
58: /* Pull parsers. */
59: #define YYPULL 1
60:
1.155 misha 61:
62:
1.154 moko 63:
1.156 moko 64: /* Copy the first part of user declarations. */
1.163 ! moko 65: #line 1 "compile.y" /* yacc.c:339 */
1.1 parser 66:
1.14 parser 67: /** @file
68: Parser: compiler(lexical parser and grammar).
69:
1.154 moko 70: Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com)
1.27 paf 71: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.109 paf 72:
1.154 moko 73:
1.14 parser 74: */
1.1 parser 75:
1.163 ! moko 76: volatile const char * IDENT_COMPILE_Y = "$Id: compile.y,v 1.271 2015/09/27 20:12:42 moko Exp $";
1.154 moko 77:
1.1 parser 78: /**
79: @todo parser4:
80: - cache compiled code from request to request. to do that...
81: -#: make method definitions, @CLASS, @BASE, @USE instructions,
82: which would be executed afterwards, and actions
83: now performed at compile time would be delayed to run time.
84: -#: make cache expiration on time and on disk-change of class source
85: -#: in apache use subpools for compiled class storage
86: -#: in iis make up specialized Pool object for that
87: */
88:
1.84 paf 89: #define YYSTYPE ArrayOperation*
1.1 parser 90: #define YYDEBUG 1
1.163 ! moko 91: #define YYERROR_VERBOSE 1
! 92: #define yyerror(pc, msg) real_yyerror(pc, msg)
1.1 parser 93: #define YYPRINT(file, type, value) yyprint(file, type, value)
1.161 moko 94: #define YYMALLOC pa_malloc
95: #define YYFREE pa_free
1.1 parser 96:
1.84 paf 97: // includes
98:
1.1 parser 99: #include "compile_tools.h"
100: #include "pa_value.h"
101: #include "pa_request.h"
102: #include "pa_vobject.h"
103: #include "pa_vdouble.h"
104: #include "pa_globals.h"
1.72 paf 105: #include "pa_vmethod_frame.h"
1.1 parser 106:
1.84 paf 107: // defines
108:
1.1 parser 109: #define USE_CONTROL_METHOD_NAME "USE"
1.119 misha 110: #define OPTIONS_CONTROL_METHOD_NAME "OPTIONS"
111: #define OPTION_ALL_VARS_LOCAL_NAME "locals"
1.123 misha 112: #define OPTION_PARTIAL_CLASS "partial"
1.131 misha 113: #define REM_OPERATOR_NAME "rem"
1.1 parser 114:
1.84 paf 115: // forwards
116:
1.156 moko 117: static int real_yyerror(Parse_control* pc, const char* s);
1.84 paf 118: static void yyprint(FILE* file, int type, YYSTYPE value);
119: static int yylex(YYSTYPE* lvalp, void* pc);
1.1 parser 120:
1.107 paf 121: static const VBool vfalse(false);
122: static const VBool vtrue(true);
1.153 moko 123: static const VString vempty;
1.107 paf 124:
1.1 parser 125: // local convinient inplace typecast & var
1.83 paf 126: #undef PC
1.163 ! moko 127: #define PC (*pc)
1.84 paf 128: #undef POOL
1.1 parser 129: #define POOL (*PC.pool)
130: #ifndef DOXYGEN
1.112 paf 131:
1.157 moko 132: #define CLASS_ADD if(PC.class_add()){ \
133: strncpy(PC.error, PC.cclass->name().cstr(), MAX_STRING/2); \
134: strcat(PC.error, " - class is already defined"); \
135: YYERROR; \
136: }
137:
138:
1.163 ! moko 139: #line 140 "compile.tab.C" /* yacc.c:339 */
1.112 paf 140:
1.163 ! moko 141: # ifndef YY_NULLPTR
! 142: # if defined __cplusplus && 201103L <= __cplusplus
! 143: # define YY_NULLPTR nullptr
! 144: # else
! 145: # define YY_NULLPTR 0
! 146: # endif
! 147: # endif
1.108 paf 148:
1.112 paf 149: /* Enabling verbose error messages. */
150: #ifdef YYERROR_VERBOSE
151: # undef YYERROR_VERBOSE
152: # define YYERROR_VERBOSE 1
153: #else
154: # define YYERROR_VERBOSE 0
1.106 paf 155: #endif
1.112 paf 156:
1.163 ! moko 157:
! 158: /* Debug traces. */
! 159: #ifndef YYDEBUG
! 160: # define YYDEBUG 0
! 161: #endif
! 162: #if YYDEBUG
! 163: extern int yydebug;
1.156 moko 164: #endif
165:
1.163 ! moko 166: /* Token type. */
1.156 moko 167: #ifndef YYTOKENTYPE
168: # define YYTOKENTYPE
1.163 ! moko 169: enum yytokentype
! 170: {
! 171: EON = 258,
! 172: STRING = 259,
! 173: BOGUS = 260,
! 174: BAD_STRING_COMPARISON_OPERATOR = 261,
! 175: BAD_HEX_LITERAL = 262,
! 176: BAD_METHOD_DECL_START = 263,
! 177: BAD_METHOD_PARAMETER_NAME_CHARACTER = 264,
! 178: BAD_NONWHITESPACE_CHARACTER_IN_EXPLICIT_RESULT_MODE = 265,
! 179: LAND = 266,
! 180: LOR = 267,
! 181: LXOR = 268,
! 182: NXOR = 269,
! 183: NLE = 270,
! 184: NGE = 271,
! 185: NEQ = 272,
! 186: NNE = 273,
! 187: NSL = 274,
! 188: NSR = 275,
! 189: SLT = 276,
! 190: SGT = 277,
! 191: SLE = 278,
! 192: SGE = 279,
! 193: SEQ = 280,
! 194: SNE = 281,
! 195: DEF = 282,
! 196: IN = 283,
! 197: FEXISTS = 284,
! 198: DEXISTS = 285,
! 199: IS = 286,
! 200: LITERAL_TRUE = 287,
! 201: LITERAL_FALSE = 288,
! 202: NUNARY = 289
! 203: };
1.156 moko 204: #endif
205:
1.163 ! moko 206: /* Value type. */
1.156 moko 207: #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1.112 paf 208: typedef int YYSTYPE;
1.156 moko 209: # define YYSTYPE_IS_TRIVIAL 1
1.112 paf 210: # define YYSTYPE_IS_DECLARED 1
211: #endif
212:
213:
1.163 ! moko 214:
! 215: int yyparse (Parse_control* pc);
! 216:
! 217:
! 218:
1.156 moko 219: /* Copy the second part of user declarations. */
220:
1.163 ! moko 221: #line 222 "compile.tab.C" /* yacc.c:358 */
1.156 moko 222:
223: #ifdef short
224: # undef short
225: #endif
226:
227: #ifdef YYTYPE_UINT8
228: typedef YYTYPE_UINT8 yytype_uint8;
229: #else
230: typedef unsigned char yytype_uint8;
231: #endif
232:
233: #ifdef YYTYPE_INT8
234: typedef YYTYPE_INT8 yytype_int8;
1.163 ! moko 235: #else
1.156 moko 236: typedef signed char yytype_int8;
237: #endif
1.155 misha 238:
1.156 moko 239: #ifdef YYTYPE_UINT16
240: typedef YYTYPE_UINT16 yytype_uint16;
241: #else
242: typedef unsigned short int yytype_uint16;
243: #endif
1.154 moko 244:
1.156 moko 245: #ifdef YYTYPE_INT16
246: typedef YYTYPE_INT16 yytype_int16;
247: #else
248: typedef short int yytype_int16;
249: #endif
1.154 moko 250:
1.156 moko 251: #ifndef YYSIZE_T
252: # ifdef __SIZE_TYPE__
253: # define YYSIZE_T __SIZE_TYPE__
254: # elif defined size_t
255: # define YYSIZE_T size_t
1.163 ! moko 256: # elif ! defined YYSIZE_T
1.156 moko 257: # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
258: # define YYSIZE_T size_t
259: # else
260: # define YYSIZE_T unsigned int
261: # endif
262: #endif
1.112 paf 263:
1.156 moko 264: #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1.112 paf 265:
1.156 moko 266: #ifndef YY_
267: # if defined YYENABLE_NLS && YYENABLE_NLS
268: # if ENABLE_NLS
269: # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1.163 ! moko 270: # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
1.156 moko 271: # endif
1.114 misha 272: # endif
1.156 moko 273: # ifndef YY_
1.163 ! moko 274: # define YY_(Msgid) Msgid
! 275: # endif
! 276: #endif
! 277:
! 278: #ifndef YY_ATTRIBUTE
! 279: # if (defined __GNUC__ \
! 280: && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
! 281: || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
! 282: # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
! 283: # else
! 284: # define YY_ATTRIBUTE(Spec) /* empty */
! 285: # endif
! 286: #endif
! 287:
! 288: #ifndef YY_ATTRIBUTE_PURE
! 289: # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
! 290: #endif
! 291:
! 292: #ifndef YY_ATTRIBUTE_UNUSED
! 293: # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
! 294: #endif
! 295:
! 296: #if !defined _Noreturn \
! 297: && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
! 298: # if defined _MSC_VER && 1200 <= _MSC_VER
! 299: # define _Noreturn __declspec (noreturn)
! 300: # else
! 301: # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
1.114 misha 302: # endif
1.156 moko 303: #endif
304:
305: /* Suppress unused-variable warnings by "using" E. */
306: #if ! defined lint || defined __GNUC__
1.163 ! moko 307: # define YYUSE(E) ((void) (E))
1.156 moko 308: #else
1.163 ! moko 309: # define YYUSE(E) /* empty */
1.156 moko 310: #endif
311:
1.163 ! moko 312: #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
! 313: /* Suppress an incorrect diagnostic about yylval being uninitialized. */
! 314: # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
! 315: _Pragma ("GCC diagnostic push") \
! 316: _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
! 317: _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
! 318: # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
! 319: _Pragma ("GCC diagnostic pop")
1.156 moko 320: #else
1.163 ! moko 321: # define YY_INITIAL_VALUE(Value) Value
! 322: #endif
! 323: #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
! 324: # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
! 325: # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1.156 moko 326: #endif
1.163 ! moko 327: #ifndef YY_INITIAL_VALUE
! 328: # define YY_INITIAL_VALUE(Value) /* Nothing. */
1.156 moko 329: #endif
330:
1.163 ! moko 331:
1.156 moko 332: #if ! defined yyoverflow || YYERROR_VERBOSE
1.114 misha 333:
1.112 paf 334: /* The parser invokes alloca or malloc; define the necessary symbols. */
335:
1.113 paf 336: # ifdef YYSTACK_USE_ALLOCA
337: # if YYSTACK_USE_ALLOCA
338: # ifdef __GNUC__
339: # define YYSTACK_ALLOC __builtin_alloca
1.156 moko 340: # elif defined __BUILTIN_VA_ARG_INCR
341: # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
342: # elif defined _AIX
343: # define YYSTACK_ALLOC __alloca
344: # elif defined _MSC_VER
345: # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
346: # define alloca _alloca
347: # else
348: # define YYSTACK_ALLOC alloca
1.163 ! moko 349: # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
1.156 moko 350: # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1.163 ! moko 351: /* Use EXIT_SUCCESS as a witness for stdlib.h. */
1.158 misha 352: # ifndef EXIT_SUCCESS
353: # define EXIT_SUCCESS 0
1.156 moko 354: # endif
355: # endif
1.112 paf 356: # endif
357: # endif
358: # endif
359:
360: # ifdef YYSTACK_ALLOC
1.163 ! moko 361: /* Pacify GCC's 'empty if-body' warning. */
! 362: # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1.156 moko 363: # ifndef YYSTACK_ALLOC_MAXIMUM
364: /* The OS might guarantee only one guard page at the bottom of the stack,
365: and a page size can be as small as 4096 bytes. So we cannot safely
366: invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
367: to allow for a few compiler-allocated temporary stack slots. */
368: # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
369: # endif
1.155 misha 370: # else
1.156 moko 371: # define YYSTACK_ALLOC YYMALLOC
372: # define YYSTACK_FREE YYFREE
373: # ifndef YYSTACK_ALLOC_MAXIMUM
374: # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
375: # endif
1.158 misha 376: # if (defined __cplusplus && ! defined EXIT_SUCCESS \
1.156 moko 377: && ! ((defined YYMALLOC || defined malloc) \
1.163 ! moko 378: && (defined YYFREE || defined free)))
1.155 misha 379: # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1.158 misha 380: # ifndef EXIT_SUCCESS
381: # define EXIT_SUCCESS 0
1.156 moko 382: # endif
383: # endif
384: # ifndef YYMALLOC
385: # define YYMALLOC malloc
1.163 ! moko 386: # if ! defined malloc && ! defined EXIT_SUCCESS
1.156 moko 387: void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
388: # endif
389: # endif
390: # ifndef YYFREE
391: # define YYFREE free
1.163 ! moko 392: # if ! defined free && ! defined EXIT_SUCCESS
1.156 moko 393: void free (void *); /* INFRINGES ON USER NAME SPACE */
394: # endif
1.154 moko 395: # endif
1.112 paf 396: # endif
1.156 moko 397: #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1.112 paf 398:
399:
1.156 moko 400: #if (! defined yyoverflow \
401: && (! defined __cplusplus \
1.163 ! moko 402: || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1.112 paf 403:
404: /* A type that is properly aligned for any stack member. */
405: union yyalloc
406: {
1.156 moko 407: yytype_int16 yyss_alloc;
408: YYSTYPE yyvs_alloc;
409: };
1.112 paf 410:
411: /* The size of the maximum gap between one aligned stack and the next. */
412: # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
413:
414: /* The size of an array large to enough to hold all stacks, each with
415: N elements. */
416: # define YYSTACK_BYTES(N) \
1.156 moko 417: ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1.112 paf 418: + YYSTACK_GAP_MAXIMUM)
419:
1.158 misha 420: # define YYCOPY_NEEDED 1
1.112 paf 421:
422: /* Relocate STACK from its old location to the new one. The
423: local variables YYSIZE and YYSTACKSIZE give the old and new number of
424: elements in the stack, and YYPTR gives the new location of the
425: stack. Advance YYPTR to a properly aligned location for the next
426: stack. */
1.163 ! moko 427: # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
! 428: do \
! 429: { \
! 430: YYSIZE_T yynewbytes; \
! 431: YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
! 432: Stack = &yyptr->Stack_alloc; \
! 433: yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
! 434: yyptr += yynewbytes / sizeof (*yyptr); \
! 435: } \
! 436: while (0)
1.108 paf 437:
1.155 misha 438: #endif
439:
1.158 misha 440: #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
1.163 ! moko 441: /* Copy COUNT objects from SRC to DST. The source and destination do
1.158 misha 442: not overlap. */
443: # ifndef YYCOPY
444: # if defined __GNUC__ && 1 < __GNUC__
1.163 ! moko 445: # define YYCOPY(Dst, Src, Count) \
! 446: __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
1.158 misha 447: # else
1.163 ! moko 448: # define YYCOPY(Dst, Src, Count) \
! 449: do \
! 450: { \
! 451: YYSIZE_T yyi; \
! 452: for (yyi = 0; yyi < (Count); yyi++) \
! 453: (Dst)[yyi] = (Src)[yyi]; \
! 454: } \
! 455: while (0)
1.158 misha 456: # endif
457: # endif
458: #endif /* !YYCOPY_NEEDED */
459:
1.156 moko 460: /* YYFINAL -- State number of the termination state. */
1.112 paf 461: #define YYFINAL 51
462: /* YYLAST -- Last index in YYTABLE. */
1.115 misha 463: #define YYLAST 470
1.112 paf 464:
1.156 moko 465: /* YYNTOKENS -- Number of terminals. */
1.112 paf 466: #define YYNTOKENS 62
1.156 moko 467: /* YYNNTS -- Number of nonterminals. */
1.115 misha 468: #define YYNNTS 89
1.156 moko 469: /* YYNRULES -- Number of rules. */
1.115 misha 470: #define YYNRULES 172
1.163 ! moko 471: /* YYNSTATES -- Number of states. */
1.115 misha 472: #define YYNSTATES 263
1.112 paf 473:
1.163 ! moko 474: /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
! 475: by yylex, with out-of-bounds checking. */
1.112 paf 476: #define YYUNDEFTOK 2
477: #define YYMAXUTOK 289
478:
1.163 ! moko 479: #define YYTRANSLATE(YYX) \
1.112 paf 480: ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
481:
1.163 ! moko 482: /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
! 483: as returned by yylex, without out-of-bounds checking. */
1.156 moko 484: static const yytype_uint8 yytranslate[] =
1.112 paf 485: {
486: 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
487: 48, 2, 2, 2, 2, 2, 2, 2, 2, 2,
488: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
489: 2, 2, 2, 46, 60, 2, 52, 43, 37, 61,
490: 56, 57, 40, 38, 2, 39, 55, 41, 2, 2,
491: 2, 2, 2, 2, 2, 2, 2, 2, 59, 51,
492: 34, 2, 35, 2, 47, 2, 2, 2, 2, 2,
493: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
494: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
495: 2, 49, 42, 50, 58, 2, 2, 2, 2, 2,
496: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
497: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
498: 2, 2, 2, 53, 36, 54, 45, 2, 2, 2,
499: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
500: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
506: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
507: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511: 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
512: 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
513: 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
514: 25, 26, 27, 28, 29, 30, 31, 32, 33, 44
515: };
1.105 paf 516:
1.112 paf 517: #if YYDEBUG
1.163 ! moko 518: /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
1.156 moko 519: static const yytype_uint16 yyrline[] =
1.112 paf 520: {
1.161 moko 521: 0, 142, 142, 149, 151, 151, 152, 154, 154, 156,
522: 266, 266, 267, 267, 268, 269, 269, 271, 271, 319,
523: 319, 320, 321, 321, 322, 322, 324, 324, 328, 328,
524: 330, 330, 331, 331, 332, 332, 332, 336, 384, 385,
525: 385, 386, 388, 389, 390, 443, 444, 444, 448, 461,
526: 462, 463, 464, 490, 495, 498, 499, 500, 502, 505,
527: 502, 513, 521, 528, 529, 530, 532, 538, 539, 539,
528: 543, 556, 559, 556, 604, 606, 606, 608, 609, 610,
529: 612, 615, 612, 618, 619, 621, 622, 625, 626, 629,
530: 630, 632, 635, 649, 654, 655, 656, 661, 661, 663,
531: 663, 664, 665, 677, 686, 689, 690, 691, 692, 694,
532: 698, 707, 710, 707, 723, 728, 728, 729, 735, 736,
533: 738, 751, 763, 765, 766, 767, 768, 769, 770, 771,
534: 772, 774, 775, 776, 777, 778, 779, 780, 781, 783,
535: 784, 785, 786, 787, 788, 789, 790, 791, 792, 793,
536: 794, 795, 796, 797, 798, 799, 800, 801, 802, 803,
537: 804, 805, 806, 807, 808, 809, 812, 817, 838, 843,
538: 844, 845, 847
1.106 paf 539: };
1.109 paf 540: #endif
1.1 parser 541:
1.163 ! moko 542: #if YYDEBUG || YYERROR_VERBOSE || 0
1.156 moko 543: /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
544: First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1.112 paf 545: static const char *const yytname[] =
546: {
1.113 paf 547: "$end", "error", "$undefined", "EON", "STRING", "BOGUS",
548: "BAD_STRING_COMPARISON_OPERATOR", "BAD_HEX_LITERAL",
549: "BAD_METHOD_DECL_START", "BAD_METHOD_PARAMETER_NAME_CHARACTER",
550: "BAD_NONWHITESPACE_CHARACTER_IN_EXPLICIT_RESULT_MODE", "\"&&\"",
551: "\"||\"", "\"!||\"", "\"!|\"", "\"<=\"", "\">=\"", "\"==\"", "\"!=\"",
552: "\"<<\"", "\">>\"", "\"lt\"", "\"gt\"", "\"le\"", "\"ge\"", "\"eq\"",
553: "\"ne\"", "\"def\"", "\"in\"", "\"-f\"", "\"-d\"", "\"is\"", "\"true\"",
554: "\"false\"", "'<'", "'>'", "'|'", "'&'", "'+'", "'-'", "'*'", "'/'",
555: "'\\\\'", "'%'", "NUNARY", "'~'", "'!'", "'@'", "'\\n'", "'['", "']'",
556: "';'", "'$'", "'{'", "'}'", "'.'", "'('", "')'", "'^'", "':'", "'\"'",
1.156 moko 557: "'\\''", "$accept", "all", "methods", "one_big_piece", "method",
1.113 paf 558: "control_method", "maybe_control_strings", "control_strings",
1.115 misha 559: "control_string", "maybe_string", "code_method", "@1",
1.113 paf 560: "maybe_bracketed_strings", "bracketed_maybe_strings", "maybe_strings",
561: "strings", "maybe_comment", "maybe_codes", "codes", "code", "action",
562: "get", "get_value", "get_name_value", "name_in_curly_rdive",
563: "name_without_curly_rdive", "name_without_curly_rdive_read",
564: "name_without_curly_rdive_class", "name_without_curly_rdive_code", "put",
565: "name_expr_wdive", "name_expr_wdive_root", "name_expr_wdive_write",
1.156 moko 566: "name_expr_wdive_class", "construct", "construct_square", "@2", "$@3",
1.113 paf 567: "construct_round", "construct_curly", "any_constructor_code_value",
568: "constructor_code_value", "constructor_code",
1.156 moko 569: "codes__excluding_sole_str_literal", "call", "call_value", "$@4", "$@5",
1.115 misha 570: "call_name", "store_params", "store_param", "store_square_param", "@6",
1.156 moko 571: "$@7", "store_round_param", "store_curly_param",
572: "store_code_param_parts", "store_expr_param_parts",
573: "store_curly_param_parts", "store_code_param_part",
574: "store_expr_param_part", "store_curly_param_part", "code_param_value",
575: "name_expr_dive_code", "name_path", "name_step", "name_advance1",
576: "name_advance2", "name_expr_value", "name_expr_subvar_value",
577: "name_expr_with_subvar_value", "name_square_code_value", "@8", "$@9",
1.113 paf 578: "subvar_ref_name_rdive", "subvar_get_writes", "subvar__get_write",
579: "class_prefix", "class_static_prefix", "class_constructor_prefix",
580: "expr_value", "expr", "double_or_STRING", "string_inside_quotes_value",
1.163 ! moko 581: "write_string", "empty_value", "true_value", "false_value", "empty", YY_NULLPTR
1.1 parser 582: };
1.106 paf 583: #endif
1.1 parser 584:
1.112 paf 585: # ifdef YYPRINT
1.163 ! moko 586: /* YYTOKNUM[NUM] -- (External) token number corresponding to the
! 587: (internal) symbol number NUM (which must be that of a token). */
1.156 moko 588: static const yytype_uint16 yytoknum[] =
1.112 paf 589: {
590: 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
591: 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
592: 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
593: 285, 286, 287, 288, 60, 62, 124, 38, 43, 45,
594: 42, 47, 92, 37, 289, 126, 33, 64, 10, 91,
595: 93, 59, 36, 123, 125, 46, 40, 41, 94, 58,
596: 34, 39
597: };
598: # endif
1.109 paf 599:
1.163 ! moko 600: #define YYPACT_NINF -107
! 601:
! 602: #define yypact_value_is_default(Yystate) \
! 603: (!!((Yystate) == (-107)))
! 604:
! 605: #define YYTABLE_NINF -173
! 606:
! 607: #define yytable_value_is_error(Yytable_value) \
! 608: 0
1.1 parser 609:
1.163 ! moko 610: /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
! 611: STATE-NUM. */
! 612: static const yytype_int16 yypact[] =
1.112 paf 613: {
1.163 ! moko 614: 14, -107, 13, 45, -107, 28, -15, -107, -107, -107,
! 615: -107, -107, 21, -107, -107, -107, -107, -107, -107, -107,
! 616: -107, -107, 73, 19, -107, 50, 6, 44, -107, -107,
! 617: 87, -107, -107, -107, -34, -107, -107, -107, -107, 65,
! 618: -107, 48, -107, 5, -107, -107, -107, 65, 24, -107,
! 619: 6, -107, -107, -107, 88, 109, 74, -107, 50, -107,
! 620: 76, -107, 21, -107, -107, 86, 65, 101, 65, 76,
! 621: -107, 44, 101, -107, -107, 21, 7, -107, -107, -107,
! 622: -107, 18, -107, -107, 5, -107, -107, -107, -107, -107,
! 623: -107, -107, -107, 9, -107, 94, 99, -107, 93, 112,
! 624: -107, 146, -107, -107, -107, -107, 21, -107, 101, 29,
! 625: 110, -107, 7, 7, 7, 7, -107, -107, 7, 7,
! 626: 7, 7, 52, 7, 21, 21, -107, -107, 113, 323,
! 627: -107, -107, -107, 92, -107, -107, -107, -107, 165, -107,
! 628: 144, -107, 147, 149, 21, 80, -107, -107, -107, -107,
! 629: -107, -107, 96, 96, 96, 96, -107, -107, -107, -107,
! 630: 276, -107, 138, 139, -107, 7, 7, 7, 7, 7,
! 631: 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
! 632: 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
! 633: 7, 7, -107, 21, 7, 35, -107, -107, -107, -107,
! 634: -107, -107, -107, 21, 154, -107, -107, -107, 419, 389,
! 635: 356, 284, 135, 135, 148, 148, 191, 191, 135, 135,
! 636: 135, 135, 148, 148, 96, 135, 135, 182, 427, 140,
! 637: 140, -107, -107, -107, -107, 37, -107, 31, -107, -30,
! 638: -107, -107, -107, -107, 21, -107, 108, -107, 155, -107,
! 639: -107, -107, 21, -107, 7, -107, -107, 37, 161, -107,
! 640: -107, -107, -107
1.108 paf 641: };
1.106 paf 642:
1.163 ! moko 643: /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
! 644: Performed when YYTABLE does not specify something else to do. Zero
! 645: means the default is an error. */
1.156 moko 646: static const yytype_uint8 yydefact[] =
1.112 paf 647: {
1.115 misha 648: 172, 168, 0, 0, 71, 0, 3, 2, 4, 7,
649: 8, 6, 29, 30, 33, 34, 37, 35, 36, 70,
650: 32, 28, 0, 105, 111, 0, 0, 0, 38, 40,
651: 0, 42, 43, 44, 0, 49, 50, 51, 52, 0,
652: 99, 0, 46, 97, 106, 107, 108, 0, 118, 119,
653: 0, 1, 5, 31, 172, 172, 172, 104, 0, 120,
654: 110, 115, 0, 114, 109, 0, 0, 103, 0, 105,
655: 53, 0, 97, 39, 58, 172, 0, 48, 55, 56,
656: 57, 105, 100, 47, 98, 101, 45, 54, 121, 74,
657: 72, 16, 9, 11, 12, 0, 10, 24, 0, 23,
658: 22, 172, 20, 19, 117, 116, 112, 41, 98, 169,
659: 0, 166, 0, 0, 0, 0, 170, 171, 0, 0,
660: 0, 0, 0, 0, 172, 172, 126, 127, 0, 122,
661: 123, 124, 125, 0, 13, 15, 14, 21, 0, 27,
662: 0, 26, 0, 168, 0, 33, 59, 65, 66, 67,
663: 63, 62, 135, 136, 137, 138, 132, 131, 133, 134,
664: 0, 167, 0, 0, 61, 0, 0, 0, 0, 0,
1.112 paf 665: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
666: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1.115 misha 667: 0, 0, 80, 172, 0, 0, 75, 77, 78, 79,
668: 25, 17, 113, 69, 0, 130, 128, 129, 150, 151,
669: 152, 149, 155, 156, 157, 158, 145, 146, 159, 160,
670: 161, 162, 163, 164, 165, 153, 154, 148, 147, 140,
671: 139, 141, 142, 144, 143, 169, 93, 0, 89, 0,
672: 87, 92, 73, 76, 172, 60, 168, 96, 81, 85,
673: 91, 94, 172, 84, 0, 83, 18, 169, 0, 90,
674: 88, 86, 82
1.1 parser 675: };
676:
1.163 ! moko 677: /* YYPGOTO[NTERM-NUM]. */
! 678: static const yytype_int16 yypgoto[] =
! 679: {
! 680: -107, -107, -107, -107, 206, -107, -107, -107, 124, -107,
! 681: -107, -107, -107, 170, -107, -107, -107, 1, -58, -7,
! 682: -106, -107, 0, -107, -107, -6, -107, -107, -21, -107,
! 683: -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
! 684: -107, 118, -107, -107, -107, 2, -107, -107, -107, -107,
! 685: 43, -107, -107, -107, -107, -107, -107, -107, -107, -17,
! 686: -13, -16, -107, -18, 4, 41, -107, -23, 3, -107,
! 687: -107, -107, -107, -107, 181, -107, 183, 239, -107, -107,
! 688: 171, 95, -107, 123, -107, 142, -107, -107, 64
! 689: };
! 690:
! 691: /* YYDEFGOTO[NTERM-NUM]. */
1.156 moko 692: static const yytype_int16 yydefgoto[] =
1.112 paf 693: {
694: -1, 5, 6, 7, 8, 9, 92, 93, 94, 95,
1.115 misha 695: 10, 244, 101, 56, 98, 99, 140, 161, 12, 13,
696: 14, 15, 126, 28, 29, 30, 31, 32, 33, 17,
697: 34, 35, 36, 37, 77, 78, 109, 204, 79, 80,
698: 146, 247, 148, 149, 18, 127, 50, 133, 90, 195,
699: 196, 197, 235, 258, 198, 199, 248, 239, 237, 249,
700: 240, 238, 250, 38, 66, 40, 41, 42, 67, 44,
701: 45, 46, 62, 142, 64, 60, 61, 68, 48, 49,
702: 241, 129, 130, 162, 20, 251, 131, 132, 21
1.105 paf 703: };
1.1 parser 704:
1.163 ! moko 705: /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
! 706: positive, shift that token. If negative, reduce the rule whose
! 707: number is the opposite. If YYTABLE_NINF, syntax error. */
1.156 moko 708: static const yytype_int16 yytable[] =
1.112 paf 709: {
1.115 misha 710: 16, 11, 19, 145, 106, 53, 43, 39, -103, 70,
711: 23, 111, 16, 91, 19, 74, 83, 22, 1, 75,
712: 65, 254, 76, 57, 57, 1, 86, 255, 51, 87,
713: 72, 71, 2, 143, 112, 113, 114, 115, 242, 116,
714: 117, 246, 84, 83, 89, 118, 119, 86, 69, 23,
715: 43, 39, 120, 121, 63, 24, 23, -172, 25, 122,
716: -102, 2, 16, 123, 19, 4, 3, 124, 125, 81,
717: 58, 58, 4, 3, 108, 16, 110, 19, 59, 4,
718: 82, 3, 252, 88, 192, 253, 203, 4, 193, 3,
719: 73, 194, 91, 24, 24, 4, 25, 25, 26, 53,
720: 27, 24, 144, 85, 25, 26, 16, 82, 19, 16,
721: 168, 19, 82, 97, 24, 173, 174, 25, 96, 100,
722: 103, 54, 55, 55, 16, 16, 19, 19, 58, 145,
723: -68, -68, 184, 185, 186, 187, 188, 189, 190, 191,
724: 107, 192, 136, 137, 16, 193, 19, -15, 194, 168,
725: 139, 145, 171, 172, 173, 174, -102, 135, -95, -95,
726: 179, 180, 168, 138, 151, 141, 181, 173, 174, 200,
727: 164, 184, 185, 186, 187, 188, 189, 190, 191, 181,
728: 188, 189, 190, 191, 184, 185, 186, 187, 188, 189,
729: 190, 191, 201, 16, 236, 19, 53, 202, 206, -64,
730: 207, 173, 174, 16, 245, 19, 257, 152, 153, 154,
731: 155, 262, 52, 156, 157, 158, 159, 134, 160, 185,
732: 186, 187, 188, 189, 190, 191, 102, 147, 144, 186,
733: 187, 188, 189, 190, 191, 16, 259, 19, 243, 104,
734: 261, 260, 47, 105, 16, 256, 19, 128, 163, 0,
735: 144, 150, 16, 236, 19, 0, 0, 16, 0, 19,
736: 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
737: 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
738: 228, 229, 230, 231, 232, 233, 234, 165, 166, 167,
739: 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
740: 178, 179, 180, 173, 174, 0, 0, 181, 0, 0,
741: 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
742: 184, 185, 186, 187, 188, 189, 190, 191, 0, 0,
743: 0, 0, 0, 205, 165, 166, 167, 168, 169, 170,
744: 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
745: 0, 0, 0, 0, 181, 0, 0, 182, 183, 184,
746: 185, 186, 187, 188, 189, 190, 191, 165, 166, 0,
747: 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
748: 178, 179, 180, 0, 0, 0, 0, 181, 0, 0,
749: 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
750: 165, 0, 0, 168, 169, 170, 171, 172, 173, 174,
751: 175, 176, 177, 178, 179, 180, 0, 0, 0, 0,
752: 181, 0, 0, 182, 183, 184, 185, 186, 187, 188,
753: 189, 190, 191, 168, 169, 170, 171, 172, 173, 174,
754: 175, 176, 177, 178, 179, 180, 173, 174, 0, 0,
755: 181, 0, 0, 182, 183, 184, 185, 186, 187, 188,
756: 189, 190, 191, 0, 0, 186, 187, 188, 189, 190,
1.112 paf 757: 191
1.1 parser 758: };
759:
1.156 moko 760: static const yytype_int16 yycheck[] =
1.112 paf 761: {
1.115 misha 762: 0, 0, 0, 109, 62, 12, 3, 3, 3, 27,
763: 4, 4, 12, 4, 12, 49, 39, 4, 4, 53,
764: 26, 51, 56, 5, 5, 4, 47, 57, 0, 47,
765: 27, 27, 47, 4, 27, 28, 29, 30, 3, 32,
766: 33, 4, 39, 66, 50, 38, 39, 68, 4, 4,
767: 47, 47, 45, 46, 4, 49, 4, 48, 52, 52,
768: 55, 47, 62, 56, 62, 58, 52, 60, 61, 4,
769: 52, 52, 58, 52, 71, 75, 75, 75, 59, 58,
770: 39, 52, 51, 59, 49, 54, 144, 58, 53, 52,
771: 3, 56, 4, 49, 49, 58, 52, 52, 53, 106,
772: 55, 49, 109, 55, 52, 53, 106, 66, 106, 109,
773: 14, 109, 71, 4, 49, 19, 20, 52, 54, 55,
774: 56, 48, 49, 49, 124, 125, 124, 125, 52, 235,
775: 50, 51, 36, 37, 38, 39, 40, 41, 42, 43,
776: 54, 49, 48, 50, 144, 53, 144, 48, 56, 14,
777: 4, 257, 17, 18, 19, 20, 55, 93, 50, 51,
778: 25, 26, 14, 51, 54, 101, 31, 19, 20, 4,
779: 57, 36, 37, 38, 39, 40, 41, 42, 43, 31,
780: 40, 41, 42, 43, 36, 37, 38, 39, 40, 41,
781: 42, 43, 48, 193, 193, 193, 203, 50, 60, 50,
782: 61, 19, 20, 203, 50, 203, 51, 112, 113, 114,
783: 115, 50, 6, 118, 119, 120, 121, 93, 123, 37,
784: 38, 39, 40, 41, 42, 43, 56, 109, 235, 38,
785: 39, 40, 41, 42, 43, 235, 252, 235, 195, 58,
786: 257, 254, 3, 60, 244, 244, 244, 76, 125, -1,
787: 257, 109, 252, 252, 252, -1, -1, 257, -1, 257,
788: 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
789: 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
790: 185, 186, 187, 188, 189, 190, 191, 11, 12, 13,
791: 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
792: 24, 25, 26, 19, 20, -1, -1, 31, -1, -1,
793: 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
794: 36, 37, 38, 39, 40, 41, 42, 43, -1, -1,
795: -1, -1, -1, 57, 11, 12, 13, 14, 15, 16,
796: 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
797: -1, -1, -1, -1, 31, -1, -1, 34, 35, 36,
798: 37, 38, 39, 40, 41, 42, 43, 11, 12, -1,
799: 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
800: 24, 25, 26, -1, -1, -1, -1, 31, -1, -1,
801: 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
802: 11, -1, -1, 14, 15, 16, 17, 18, 19, 20,
803: 21, 22, 23, 24, 25, 26, -1, -1, -1, -1,
804: 31, -1, -1, 34, 35, 36, 37, 38, 39, 40,
805: 41, 42, 43, 14, 15, 16, 17, 18, 19, 20,
806: 21, 22, 23, 24, 25, 26, 19, 20, -1, -1,
807: 31, -1, -1, 34, 35, 36, 37, 38, 39, 40,
808: 41, 42, 43, -1, -1, 38, 39, 40, 41, 42,
1.112 paf 809: 43
1.1 parser 810: };
811:
1.163 ! moko 812: /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
! 813: symbol of state STATE-NUM. */
1.156 moko 814: static const yytype_uint8 yystos[] =
1.112 paf 815: {
816: 0, 4, 47, 52, 58, 63, 64, 65, 66, 67,
1.115 misha 817: 72, 79, 80, 81, 82, 83, 84, 91, 106, 107,
818: 146, 150, 4, 4, 49, 52, 53, 55, 85, 86,
819: 87, 88, 89, 90, 92, 93, 94, 95, 125, 126,
820: 127, 128, 129, 130, 131, 132, 133, 139, 140, 141,
821: 108, 0, 66, 81, 48, 49, 75, 5, 52, 59,
822: 137, 138, 134, 4, 136, 87, 126, 130, 139, 4,
823: 125, 126, 130, 3, 49, 53, 56, 96, 97, 100,
824: 101, 4, 127, 129, 130, 55, 90, 125, 59, 87,
825: 110, 4, 68, 69, 70, 71, 150, 4, 76, 77,
826: 150, 74, 75, 150, 136, 138, 80, 54, 130, 98,
827: 79, 4, 27, 28, 29, 30, 32, 33, 38, 39,
828: 45, 46, 52, 56, 60, 61, 84, 107, 142, 143,
829: 144, 148, 149, 109, 70, 150, 48, 50, 51, 4,
830: 78, 150, 135, 4, 81, 82, 102, 103, 104, 105,
831: 147, 54, 143, 143, 143, 143, 143, 143, 143, 143,
832: 143, 79, 145, 145, 57, 11, 12, 13, 14, 15,
1.112 paf 833: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
834: 26, 31, 34, 35, 36, 37, 38, 39, 40, 41,
1.115 misha 835: 42, 43, 49, 53, 56, 111, 112, 113, 116, 117,
836: 4, 48, 50, 80, 99, 57, 60, 61, 143, 143,
837: 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
838: 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
839: 143, 143, 143, 143, 143, 114, 79, 120, 123, 119,
840: 122, 142, 3, 112, 73, 50, 4, 103, 118, 121,
841: 124, 147, 51, 54, 51, 57, 79, 51, 115, 123,
842: 122, 121, 50
1.1 parser 843: };
1.109 paf 844:
1.163 ! moko 845: /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
! 846: static const yytype_uint8 yyr1[] =
! 847: {
! 848: 0, 62, 63, 63, 64, 64, 65, 66, 66, 67,
! 849: 68, 68, 69, 69, 70, 71, 71, 73, 72, 74,
! 850: 74, 75, 76, 76, 77, 77, 78, 78, 79, 79,
! 851: 80, 80, 81, 81, 82, 82, 82, 83, 84, 85,
! 852: 85, 86, 87, 87, 88, 89, 90, 90, 91, 92,
! 853: 92, 92, 93, 94, 95, 96, 96, 96, 98, 99,
! 854: 97, 100, 101, 102, 102, 102, 103, 104, 105, 105,
! 855: 106, 108, 109, 107, 110, 111, 111, 112, 112, 112,
! 856: 114, 115, 113, 116, 117, 118, 118, 119, 119, 120,
! 857: 120, 121, 122, 123, 124, 124, 124, 125, 125, 126,
! 858: 126, 127, 128, 129, 129, 130, 130, 130, 130, 131,
! 859: 132, 134, 135, 133, 136, 137, 137, 138, 139, 139,
! 860: 140, 141, 142, 143, 143, 143, 143, 143, 143, 143,
! 861: 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
! 862: 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
! 863: 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
! 864: 143, 143, 143, 143, 143, 143, 144, 145, 146, 147,
! 865: 148, 149, 150
! 866: };
1.112 paf 867:
1.163 ! moko 868: /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
! 869: static const yytype_uint8 yyr2[] =
! 870: {
! 871: 0, 2, 1, 1, 1, 2, 1, 1, 1, 4,
! 872: 1, 1, 1, 2, 2, 1, 1, 0, 8, 1,
! 873: 1, 3, 1, 1, 1, 3, 1, 1, 1, 1,
! 874: 1, 2, 1, 1, 1, 1, 1, 1, 2, 2,
! 875: 1, 3, 1, 1, 1, 2, 1, 2, 3, 1,
! 876: 1, 1, 1, 2, 2, 1, 1, 1, 0, 0,
! 877: 5, 3, 3, 1, 1, 1, 1, 1, 1, 2,
! 878: 1, 0, 0, 6, 1, 1, 2, 1, 1, 1,
! 879: 0, 0, 5, 3, 3, 1, 3, 1, 3, 1,
! 880: 3, 1, 1, 1, 1, 1, 1, 1, 2, 1,
! 881: 2, 2, 1, 1, 2, 1, 1, 1, 1, 2,
! 882: 2, 0, 0, 5, 1, 1, 2, 2, 1, 1,
! 883: 2, 2, 1, 1, 1, 1, 1, 1, 3, 3,
! 884: 3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
! 885: 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
! 886: 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
! 887: 3, 3, 3, 3, 3, 3, 1, 1, 1, 0,
! 888: 1, 1, 0
! 889: };
1.112 paf 890:
1.156 moko 891:
1.163 ! moko 892: #define yyerrok (yyerrstatus = 0)
! 893: #define yyclearin (yychar = YYEMPTY)
! 894: #define YYEMPTY (-2)
! 895: #define YYEOF 0
! 896:
! 897: #define YYACCEPT goto yyacceptlab
! 898: #define YYABORT goto yyabortlab
! 899: #define YYERROR goto yyerrorlab
1.156 moko 900:
901:
1.163 ! moko 902: #define YYRECOVERING() (!!yyerrstatus)
1.108 paf 903:
1.163 ! moko 904: #define YYBACKUP(Token, Value) \
! 905: do \
! 906: if (yychar == YYEMPTY) \
! 907: { \
! 908: yychar = (Token); \
! 909: yylval = (Value); \
! 910: YYPOPSTACK (yylen); \
! 911: yystate = *yyssp; \
! 912: goto yybackup; \
! 913: } \
! 914: else \
! 915: { \
! 916: yyerror (pc, YY_("syntax error: cannot back up")); \
! 917: YYERROR; \
! 918: } \
! 919: while (0)
! 920:
! 921: /* Error token number */
! 922: #define YYTERROR 1
! 923: #define YYERRCODE 256
1.156 moko 924:
1.112 paf 925:
926:
927: /* Enable debugging if requested. */
928: #if YYDEBUG
929:
930: # ifndef YYFPRINTF
931: # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
932: # define YYFPRINTF fprintf
933: # endif
934:
1.163 ! moko 935: # define YYDPRINTF(Args) \
! 936: do { \
! 937: if (yydebug) \
! 938: YYFPRINTF Args; \
! 939: } while (0)
! 940:
! 941: /* This macro is provided for backward compatibility. */
! 942: #ifndef YY_LOCATION_PRINT
! 943: # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
! 944: #endif
! 945:
1.156 moko 946:
1.163 ! moko 947: # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
! 948: do { \
! 949: if (yydebug) \
! 950: { \
! 951: YYFPRINTF (stderr, "%s ", Title); \
! 952: yy_symbol_print (stderr, \
! 953: Type, Value, pc); \
! 954: YYFPRINTF (stderr, "\n"); \
! 955: } \
! 956: } while (0)
1.154 moko 957:
1.156 moko 958:
1.163 ! moko 959: /*----------------------------------------.
! 960: | Print this symbol's value on YYOUTPUT. |
! 961: `----------------------------------------*/
! 962:
1.156 moko 963: static void
1.163 ! moko 964: yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Parse_control* pc)
1.156 moko 965: {
1.163 ! moko 966: FILE *yyo = yyoutput;
! 967: YYUSE (yyo);
! 968: YYUSE (pc);
1.156 moko 969: if (!yyvaluep)
970: return;
971: # ifdef YYPRINT
972: if (yytype < YYNTOKENS)
973: YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
974: # endif
1.163 ! moko 975: YYUSE (yytype);
1.156 moko 976: }
977:
978:
979: /*--------------------------------.
980: | Print this symbol on YYOUTPUT. |
981: `--------------------------------*/
982:
983: static void
1.163 ! moko 984: yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Parse_control* pc)
1.156 moko 985: {
1.163 ! moko 986: YYFPRINTF (yyoutput, "%s %s (",
! 987: yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
1.154 moko 988:
1.163 ! moko 989: yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc);
1.156 moko 990: YYFPRINTF (yyoutput, ")");
991: }
1.112 paf 992:
993: /*------------------------------------------------------------------.
994: | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1.113 paf 995: | TOP (included). |
1.112 paf 996: `------------------------------------------------------------------*/
997:
998: static void
1.156 moko 999: yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1.112 paf 1000: {
1001: YYFPRINTF (stderr, "Stack now");
1.156 moko 1002: for (; yybottom <= yytop; yybottom++)
1003: {
1004: int yybot = *yybottom;
1005: YYFPRINTF (stderr, " %d", yybot);
1006: }
1.112 paf 1007: YYFPRINTF (stderr, "\n");
1008: }
1.108 paf 1009:
1.163 ! moko 1010: # define YY_STACK_PRINT(Bottom, Top) \
! 1011: do { \
! 1012: if (yydebug) \
! 1013: yy_stack_print ((Bottom), (Top)); \
! 1014: } while (0)
1.108 paf 1015:
1016:
1.112 paf 1017: /*------------------------------------------------.
1018: | Report that the YYRULE is going to be reduced. |
1019: `------------------------------------------------*/
1.108 paf 1020:
1.112 paf 1021: static void
1.163 ! moko 1022: yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, Parse_control* pc)
1.112 paf 1023: {
1.163 ! moko 1024: unsigned long int yylno = yyrline[yyrule];
1.156 moko 1025: int yynrhs = yyr2[yyrule];
1.112 paf 1026: int yyi;
1.156 moko 1027: YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1.163 ! moko 1028: yyrule - 1, yylno);
1.156 moko 1029: /* The symbols being reduced. */
1030: for (yyi = 0; yyi < yynrhs; yyi++)
1031: {
1032: YYFPRINTF (stderr, " $%d = ", yyi + 1);
1.163 ! moko 1033: yy_symbol_print (stderr,
! 1034: yystos[yyssp[yyi + 1 - yynrhs]],
! 1035: &(yyvsp[(yyi + 1) - (yynrhs)])
! 1036: , pc);
1.156 moko 1037: YYFPRINTF (stderr, "\n");
1038: }
1.112 paf 1039: }
1.105 paf 1040:
1.163 ! moko 1041: # define YY_REDUCE_PRINT(Rule) \
! 1042: do { \
! 1043: if (yydebug) \
! 1044: yy_reduce_print (yyssp, yyvsp, Rule, pc); \
! 1045: } while (0)
1.112 paf 1046:
1047: /* Nonzero means print parse trace. It is left uninitialized so that
1048: multiple parsers can coexist. */
1049: int yydebug;
1050: #else /* !YYDEBUG */
1051: # define YYDPRINTF(Args)
1.156 moko 1052: # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1.112 paf 1053: # define YY_STACK_PRINT(Bottom, Top)
1054: # define YY_REDUCE_PRINT(Rule)
1055: #endif /* !YYDEBUG */
1.1 parser 1056:
1057:
1.112 paf 1058: /* YYINITDEPTH -- initial size of the parser's stacks. */
1.163 ! moko 1059: #ifndef YYINITDEPTH
1.112 paf 1060: # define YYINITDEPTH 200
1.1 parser 1061: #endif
1062:
1.112 paf 1063: /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1064: if the built-in stack extension method is used).
1065:
1066: Do not make this value too large; the results are undefined if
1.156 moko 1067: YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1.112 paf 1068: evaluated with infinite-precision integer arithmetic. */
1.1 parser 1069:
1070: #ifndef YYMAXDEPTH
1.112 paf 1071: # define YYMAXDEPTH 10000
1.1 parser 1072: #endif
1.112 paf 1073:
1.1 parser 1074:
1.112 paf 1075: #if YYERROR_VERBOSE
1076:
1077: # ifndef yystrlen
1.156 moko 1078: # if defined __GLIBC__ && defined _STRING_H
1.112 paf 1079: # define yystrlen strlen
1080: # else
1081: /* Return the length of YYSTR. */
1082: static YYSIZE_T
1083: yystrlen (const char *yystr)
1084: {
1.156 moko 1085: YYSIZE_T yylen;
1086: for (yylen = 0; yystr[yylen]; yylen++)
1.112 paf 1087: continue;
1.156 moko 1088: return yylen;
1.112 paf 1089: }
1090: # endif
1091: # endif
1092:
1093: # ifndef yystpcpy
1.156 moko 1094: # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1.112 paf 1095: # define yystpcpy stpcpy
1096: # else
1097: /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1098: YYDEST. */
1099: static char *
1100: yystpcpy (char *yydest, const char *yysrc)
1101: {
1.156 moko 1102: char *yyd = yydest;
1103: const char *yys = yysrc;
1.112 paf 1104:
1105: while ((*yyd++ = *yys++) != '\0')
1106: continue;
1.105 paf 1107:
1.112 paf 1108: return yyd - 1;
1.105 paf 1109: }
1.112 paf 1110: # endif
1111: # endif
1112:
1.156 moko 1113: # ifndef yytnamerr
1114: /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1115: quotes and backslashes, so that it's suitable for yyerror. The
1116: heuristic is that double-quoting is unnecessary unless the string
1117: contains an apostrophe, a comma, or backslash (other than
1118: backslash-backslash). YYSTR is taken from yytname. If YYRES is
1119: null, do not copy; instead, return the length of what the result
1120: would have been. */
1121: static YYSIZE_T
1122: yytnamerr (char *yyres, const char *yystr)
1123: {
1124: if (*yystr == '"')
1125: {
1126: YYSIZE_T yyn = 0;
1127: char const *yyp = yystr;
1.154 moko 1128:
1.156 moko 1129: for (;;)
1.163 ! moko 1130: switch (*++yyp)
! 1131: {
! 1132: case '\'':
! 1133: case ',':
! 1134: goto do_not_strip_quotes;
! 1135:
! 1136: case '\\':
! 1137: if (*++yyp != '\\')
! 1138: goto do_not_strip_quotes;
! 1139: /* Fall through. */
! 1140: default:
! 1141: if (yyres)
! 1142: yyres[yyn] = *yyp;
! 1143: yyn++;
! 1144: break;
! 1145:
! 1146: case '"':
! 1147: if (yyres)
! 1148: yyres[yyn] = '\0';
! 1149: return yyn;
! 1150: }
1.156 moko 1151: do_not_strip_quotes: ;
1152: }
1153:
1154: if (! yyres)
1155: return yystrlen (yystr);
1.112 paf 1156:
1.156 moko 1157: return yystpcpy (yyres, yystr) - yyres;
1158: }
1159: # endif
1.105 paf 1160:
1.158 misha 1161: /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1162: about the unexpected token YYTOKEN for the state stack whose top is
1163: YYSSP.
1164:
1165: Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1166: not large enough to hold the message. In that case, also set
1167: *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1168: required number of bytes is too large to store. */
1169: static int
1170: yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1171: yytype_int16 *yyssp, int yytoken)
1.1 parser 1172: {
1.163 ! moko 1173: YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1.158 misha 1174: YYSIZE_T yysize = yysize0;
1175: enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1176: /* Internationalized format string. */
1.163 ! moko 1177: const char *yyformat = YY_NULLPTR;
1.158 misha 1178: /* Arguments of yyformat. */
1179: char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1180: /* Number of reported tokens (one for the "unexpected", one per
1181: "expected"). */
1182: int yycount = 0;
1183:
1184: /* There are many possibilities here to consider:
1185: - If this state is a consistent state with a default action, then
1186: the only way this function was invoked is if the default action
1187: is an error action. In that case, don't check for expected
1188: tokens because there are none.
1189: - The only way there can be no lookahead present (in yychar) is if
1190: this state is a consistent state with a default action. Thus,
1191: detecting the absence of a lookahead is sufficient to determine
1192: that there is no unexpected or expected token to report. In that
1193: case, just report a simple "syntax error".
1194: - Don't assume there isn't a lookahead just because this state is a
1195: consistent state with a default action. There might have been a
1196: previous inconsistent state, consistent state with a non-default
1197: action, or user semantic action that manipulated yychar.
1198: - Of course, the expected token list depends on states to have
1199: correct lookahead information, and it depends on the parser not
1200: to perform extra reductions after fetching a lookahead from the
1201: scanner and before detecting a syntax error. Thus, state merging
1202: (from LALR or IELR) and default reductions corrupt the expected
1203: token list. However, the list is correct for canonical LR with
1204: one exception: it will still contain any token that will not be
1205: accepted due to an error action in a later state.
1206: */
1207: if (yytoken != YYEMPTY)
1208: {
1209: int yyn = yypact[*yyssp];
1210: yyarg[yycount++] = yytname[yytoken];
1211: if (!yypact_value_is_default (yyn))
1212: {
1213: /* Start YYX at -YYN if negative to avoid negative indexes in
1214: YYCHECK. In other words, skip the first -YYN actions for
1215: this state because they are default actions. */
1216: int yyxbegin = yyn < 0 ? -yyn : 0;
1217: /* Stay within bounds of both yycheck and yytname. */
1218: int yychecklim = YYLAST - yyn + 1;
1219: int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1220: int yyx;
1221:
1222: for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1223: if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1224: && !yytable_value_is_error (yytable[yyx + yyn]))
1225: {
1226: if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1227: {
1228: yycount = 1;
1229: yysize = yysize0;
1230: break;
1231: }
1232: yyarg[yycount++] = yytname[yyx];
1.163 ! moko 1233: {
! 1234: YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
! 1235: if (! (yysize <= yysize1
! 1236: && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
! 1237: return 2;
! 1238: yysize = yysize1;
! 1239: }
1.158 misha 1240: }
1241: }
1242: }
1.112 paf 1243:
1.158 misha 1244: switch (yycount)
1.112 paf 1245: {
1.158 misha 1246: # define YYCASE_(N, S) \
1247: case N: \
1248: yyformat = S; \
1249: break
1250: YYCASE_(0, YY_("syntax error"));
1251: YYCASE_(1, YY_("syntax error, unexpected %s"));
1252: YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1253: YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1254: YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1255: YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1256: # undef YYCASE_
1257: }
1.156 moko 1258:
1.163 ! moko 1259: {
! 1260: YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
! 1261: if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
! 1262: return 2;
! 1263: yysize = yysize1;
! 1264: }
1.158 misha 1265:
1266: if (*yymsg_alloc < yysize)
1267: {
1268: *yymsg_alloc = 2 * yysize;
1269: if (! (yysize <= *yymsg_alloc
1270: && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1271: *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1272: return 1;
1273: }
1.156 moko 1274:
1.158 misha 1275: /* Avoid sprintf, as that infringes on the user's name space.
1276: Don't have undefined behavior even if the translation
1277: produced a string with the wrong number of "%s"s. */
1278: {
1279: char *yyp = *yymsg;
1280: int yyi = 0;
1281: while ((*yyp = *yyformat) != '\0')
1282: if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1283: {
1284: yyp += yytnamerr (yyp, yyarg[yyi++]);
1285: yyformat += 2;
1286: }
1287: else
1288: {
1289: yyp++;
1290: yyformat++;
1291: }
1292: }
1293: return 0;
1.1 parser 1294: }
1.156 moko 1295: #endif /* YYERROR_VERBOSE */
1.1 parser 1296:
1.112 paf 1297: /*-----------------------------------------------.
1298: | Release the memory associated to this symbol. |
1299: `-----------------------------------------------*/
1300:
1301: static void
1.163 ! moko 1302: yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Parse_control* pc)
1.112 paf 1303: {
1.156 moko 1304: YYUSE (yyvaluep);
1.163 ! moko 1305: YYUSE (pc);
1.156 moko 1306: if (!yymsg)
1307: yymsg = "Deleting";
1308: YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1.112 paf 1309:
1.163 ! moko 1310: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
! 1311: YYUSE (yytype);
! 1312: YY_IGNORE_MAYBE_UNINITIALIZED_END
1.112 paf 1313: }
1.1 parser 1314:
1.158 misha 1315:
1.112 paf 1316:
1317:
1.158 misha 1318: /*----------.
1319: | yyparse. |
1320: `----------*/
1.1 parser 1321:
1.112 paf 1322: int
1.163 ! moko 1323: yyparse (Parse_control* pc)
1.112 paf 1324: {
1.156 moko 1325: /* The lookahead symbol. */
1.112 paf 1326: int yychar;
1327:
1.163 ! moko 1328:
1.112 paf 1329: /* The semantic value of the lookahead symbol. */
1.163 ! moko 1330: /* Default value used for initialization, for pacifying older GCCs
! 1331: or non-GCC compilers. */
! 1332: YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
! 1333: YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1.112 paf 1334:
1.156 moko 1335: /* Number of syntax errors so far. */
1336: int yynerrs;
1.155 misha 1337:
1.156 moko 1338: int yystate;
1339: /* Number of tokens to shift before error messages enabled. */
1340: int yyerrstatus;
1.155 misha 1341:
1.156 moko 1342: /* The stacks and their tools:
1.163 ! moko 1343: 'yyss': related to states.
! 1344: 'yyvs': related to semantic values.
1.109 paf 1345:
1.163 ! moko 1346: Refer to the stacks through separate pointers, to allow yyoverflow
1.156 moko 1347: to reallocate them elsewhere. */
1.112 paf 1348:
1.156 moko 1349: /* The state stack. */
1350: yytype_int16 yyssa[YYINITDEPTH];
1351: yytype_int16 *yyss;
1352: yytype_int16 *yyssp;
1.112 paf 1353:
1.156 moko 1354: /* The semantic value stack. */
1355: YYSTYPE yyvsa[YYINITDEPTH];
1356: YYSTYPE *yyvs;
1357: YYSTYPE *yyvsp;
1.112 paf 1358:
1.156 moko 1359: YYSIZE_T yystacksize;
1.112 paf 1360:
1.156 moko 1361: int yyn;
1362: int yyresult;
1363: /* Lookahead token as an internal (translated) token number. */
1.163 ! moko 1364: int yytoken = 0;
1.112 paf 1365: /* The variables used to return semantic value and location from the
1366: action routines. */
1367: YYSTYPE yyval;
1.1 parser 1368:
1.156 moko 1369: #if YYERROR_VERBOSE
1370: /* Buffer for error messages, and its allocated size. */
1371: char yymsgbuf[128];
1372: char *yymsg = yymsgbuf;
1373: YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1374: #endif
1375:
1376: #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1377:
1378: /* The number of symbols on the RHS of the reduced rule.
1379: Keep to zero when no symbol should be popped. */
1380: int yylen = 0;
1381:
1.163 ! moko 1382: yyssp = yyss = yyssa;
! 1383: yyvsp = yyvs = yyvsa;
1.156 moko 1384: yystacksize = YYINITDEPTH;
1.1 parser 1385:
1.112 paf 1386: YYDPRINTF ((stderr, "Starting parse\n"));
1.1 parser 1387:
1388: yystate = 0;
1389: yyerrstatus = 0;
1390: yynerrs = 0;
1.156 moko 1391: yychar = YYEMPTY; /* Cause a token to be read. */
1.112 paf 1392: goto yysetstate;
1393:
1394: /*------------------------------------------------------------.
1395: | yynewstate -- Push a new state, which is found in yystate. |
1396: `------------------------------------------------------------*/
1397: yynewstate:
1398: /* In all cases, when you get here, the value and location stacks
1.156 moko 1399: have just been pushed. So pushing a state here evens the stacks. */
1.112 paf 1400: yyssp++;
1.105 paf 1401:
1.112 paf 1402: yysetstate:
1403: *yyssp = yystate;
1.108 paf 1404:
1.112 paf 1405: if (yyss + yystacksize - 1 <= yyssp)
1.109 paf 1406: {
1.1 parser 1407: /* Get the current used size of the three stacks, in elements. */
1.112 paf 1408: YYSIZE_T yysize = yyssp - yyss + 1;
1.1 parser 1409:
1410: #ifdef yyoverflow
1.112 paf 1411: {
1.163 ! moko 1412: /* Give user a chance to reallocate the stack. Use copies of
! 1413: these so that the &'s don't force the real ones into
! 1414: memory. */
! 1415: YYSTYPE *yyvs1 = yyvs;
! 1416: yytype_int16 *yyss1 = yyss;
! 1417:
! 1418: /* Each stack pointer address is followed by the size of the
! 1419: data in use in that stack, in bytes. This used to be a
! 1420: conditional around just the two extra args, but that might
! 1421: be undefined if yyoverflow is a macro. */
! 1422: yyoverflow (YY_("memory exhausted"),
! 1423: &yyss1, yysize * sizeof (*yyssp),
! 1424: &yyvs1, yysize * sizeof (*yyvsp),
! 1425: &yystacksize);
1.112 paf 1426:
1.163 ! moko 1427: yyss = yyss1;
! 1428: yyvs = yyvs1;
1.112 paf 1429: }
1.1 parser 1430: #else /* no yyoverflow */
1.112 paf 1431: # ifndef YYSTACK_RELOCATE
1.156 moko 1432: goto yyexhaustedlab;
1.112 paf 1433: # else
1.1 parser 1434: /* Extend the stack our own way. */
1.112 paf 1435: if (YYMAXDEPTH <= yystacksize)
1.163 ! moko 1436: goto yyexhaustedlab;
1.1 parser 1437: yystacksize *= 2;
1.112 paf 1438: if (YYMAXDEPTH < yystacksize)
1.163 ! moko 1439: yystacksize = YYMAXDEPTH;
1.112 paf 1440:
1441: {
1.163 ! moko 1442: yytype_int16 *yyss1 = yyss;
! 1443: union yyalloc *yyptr =
! 1444: (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
! 1445: if (! yyptr)
! 1446: goto yyexhaustedlab;
! 1447: YYSTACK_RELOCATE (yyss_alloc, yyss);
! 1448: YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1.112 paf 1449: # undef YYSTACK_RELOCATE
1.163 ! moko 1450: if (yyss1 != yyssa)
! 1451: YYSTACK_FREE (yyss1);
1.112 paf 1452: }
1453: # endif
1.1 parser 1454: #endif /* no yyoverflow */
1455:
1.112 paf 1456: yyssp = yyss + yysize - 1;
1457: yyvsp = yyvs + yysize - 1;
1458:
1459: YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1.163 ! moko 1460: (unsigned long int) yystacksize));
1.105 paf 1461:
1.112 paf 1462: if (yyss + yystacksize - 1 <= yyssp)
1.163 ! moko 1463: YYABORT;
1.1 parser 1464: }
1465:
1.112 paf 1466: YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1.1 parser 1467:
1.156 moko 1468: if (yystate == YYFINAL)
1469: YYACCEPT;
1470:
1.1 parser 1471: goto yybackup;
1.112 paf 1472:
1473: /*-----------.
1474: | yybackup. |
1475: `-----------*/
1476: yybackup:
1.1 parser 1477:
1.156 moko 1478: /* Do appropriate processing given the current state. Read a
1479: lookahead token if we need one and don't already have one. */
1.1 parser 1480:
1481: /* First try to decide what to do without reference to lookahead token. */
1482: yyn = yypact[yystate];
1.158 misha 1483: if (yypact_value_is_default (yyn))
1.1 parser 1484: goto yydefault;
1485:
1486: /* Not known => get a lookahead token if don't already have one. */
1487:
1.112 paf 1488: /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1.1 parser 1489: if (yychar == YYEMPTY)
1490: {
1.112 paf 1491: YYDPRINTF ((stderr, "Reading a token: "));
1.163 ! moko 1492: yychar = yylex (&yylval, pc);
1.1 parser 1493: }
1494:
1.112 paf 1495: if (yychar <= YYEOF)
1.1 parser 1496: {
1.112 paf 1497: yychar = yytoken = YYEOF;
1498: YYDPRINTF ((stderr, "Now at end of input.\n"));
1.1 parser 1499: }
1500: else
1501: {
1.112 paf 1502: yytoken = YYTRANSLATE (yychar);
1.156 moko 1503: YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1.1 parser 1504: }
1505:
1.112 paf 1506: /* If the proper action on seeing token YYTOKEN is to reduce or to
1507: detect an error, take that action. */
1508: yyn += yytoken;
1509: if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1.1 parser 1510: goto yydefault;
1511: yyn = yytable[yyn];
1.112 paf 1512: if (yyn <= 0)
1.1 parser 1513: {
1.158 misha 1514: if (yytable_value_is_error (yyn))
1515: goto yyerrlab;
1.1 parser 1516: yyn = -yyn;
1517: goto yyreduce;
1518: }
1519:
1.156 moko 1520: /* Count tokens shifted since error; after three, turn off error
1521: status. */
1522: if (yyerrstatus)
1523: yyerrstatus--;
1.155 misha 1524:
1525: /* Shift the lookahead token. */
1.156 moko 1526: YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1.155 misha 1527:
1.156 moko 1528: /* Discard the shifted token. */
1529: yychar = YYEMPTY;
1.155 misha 1530:
1.156 moko 1531: yystate = yyn;
1.163 ! moko 1532: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1.155 misha 1533: *++yyvsp = yylval;
1.163 ! moko 1534: YY_IGNORE_MAYBE_UNINITIALIZED_END
1.155 misha 1535:
1.1 parser 1536: goto yynewstate;
1537:
1.112 paf 1538:
1539: /*-----------------------------------------------------------.
1540: | yydefault -- do the default action for the current state. |
1541: `-----------------------------------------------------------*/
1.109 paf 1542: yydefault:
1.1 parser 1543: yyn = yydefact[yystate];
1544: if (yyn == 0)
1545: goto yyerrlab;
1.112 paf 1546: goto yyreduce;
1547:
1.105 paf 1548:
1.112 paf 1549: /*-----------------------------.
1550: | yyreduce -- Do a reduction. |
1551: `-----------------------------*/
1.1 parser 1552: yyreduce:
1.112 paf 1553: /* yyn is the number of a rule to reduce with. */
1.1 parser 1554: yylen = yyr2[yyn];
1.109 paf 1555:
1.112 paf 1556: /* If YYLEN is nonzero, implement the default value of the action:
1.163 ! moko 1557: '$$ = $1'.
1.109 paf 1558:
1.112 paf 1559: Otherwise, the following line sets YYVAL to garbage.
1560: This behavior is undocumented and Bison
1561: users should not rely upon it. Assigning to YYVAL
1562: unconditionally makes the parser a bit smaller, and it avoids a
1563: GCC warning that YYVAL may be used uninitialized. */
1564: yyval = yyvsp[1-yylen];
1.106 paf 1565:
1.1 parser 1566:
1.112 paf 1567: YY_REDUCE_PRINT (yyn);
1568: switch (yyn)
1569: {
1570: case 2:
1.163 ! moko 1571: #line 142 "compile.y" /* yacc.c:1646 */
1.112 paf 1572: {
1.144 misha 1573: Method* method=new Method(Method::CT_ANY,
1.1 parser 1574: 0, 0, /*min, max numbered_params_count*/
1575: 0/*param_names*/, 0/*local_names*/,
1.163 ! moko 1576: (yyvsp[0])/*parser_code*/, 0/*native_code*/);
1.144 misha 1577: PC.cclass->set_method(PC.alias_method(main_method_name), method);
1.158 misha 1578: }
1.163 ! moko 1579: #line 1580 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1580: break;
1581:
1582: case 9:
1.163 ! moko 1583: #line 157 "compile.y" /* yacc.c:1646 */
1.112 paf 1584: {
1.163 ! moko 1585: const String& command=LA2S(*(yyvsp[-2]))->trim(String::TRIM_END);
! 1586: YYSTYPE strings_code=(yyvsp[0]);
1.84 paf 1587: if(strings_code->count()<1*OPERATIONS_PER_OPVALUE) {
1.1 parser 1588: strcpy(PC.error, "@");
1589: strcat(PC.error, command.cstr());
1590: strcat(PC.error, " is empty");
1591: YYERROR;
1592: }
1593: if(command==CLASS_NAME) {
1.84 paf 1594: if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) {
1.157 moko 1595: CLASS_ADD;
1.1 parser 1596: // new class' name
1.152 misha 1597: const String& name=LA2S(*strings_code)->trim(String::TRIM_END);
1.1 parser 1598: // creating the class
1.84 paf 1599: VStateless_class* cclass=new VClass;
1.119 misha 1600: PC.cclass_new=cclass;
1601: PC.cclass_new->set_name(name);
1.158 misha 1602: PC.append=false;
1.1 parser 1603: } else {
1.160 moko 1604: strcpy(PC.error, "@" CLASS_NAME " must contain only one line with class name (contains more then one)");
1.1 parser 1605: YYERROR;
1606: }
1607: } else if(command==USE_CONTROL_METHOD_NAME) {
1.157 moko 1608: CLASS_ADD;
1.84 paf 1609: for(size_t i=0; i<strings_code->count(); i+=OPERATIONS_PER_OPVALUE)
1.152 misha 1610: PC.request.use_file(PC.request.main_class, LA2S(*strings_code, i)->trim(String::TRIM_END), PC.request.get_used_filename(PC.file_no));
1.1 parser 1611: } else if(command==BASE_NAME) {
1.119 misha 1612: if(PC.append){
1613: strcpy(PC.error, "can't set base while appending methods to class '");
1614: strncat(PC.error, PC.cclass->name().cstr(), MAX_STRING/2);
1615: strcat(PC.error, "'");
1616: YYERROR;
1617: }
1.157 moko 1618: CLASS_ADD;
1.59 paf 1619: if(PC.cclass->base_class()) { // already changed from default?
1.1 parser 1620: strcpy(PC.error, "class already have a base '");
1.119 misha 1621: strncat(PC.error, PC.cclass->base_class()->name().cstr(), MAX_STRING/2);
1.1 parser 1622: strcat(PC.error, "'");
1623: YYERROR;
1624: }
1.84 paf 1625: if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) {
1.152 misha 1626: const String& base_name=LA2S(*strings_code)->trim(String::TRIM_END);
1.145 misha 1627: if(Value* base_class_value=PC.request.get_class(base_name)) {
1.84 paf 1628: // @CLASS == @BASE sanity check
1629: if(VStateless_class *base_class=base_class_value->get_class()) {
1630: if(PC.cclass==base_class) {
1.160 moko 1631: strcpy(PC.error, "@" CLASS_NAME " equals @" BASE_NAME);
1.84 paf 1632: YYERROR;
1633: }
1634: PC.cclass->get_class()->set_base(base_class);
1635: } else { // they asked to derive from a class without methods ['env' & co]
1636: strcpy(PC.error, base_name.cstr());
1.160 moko 1637: strcat(PC.error, ": you can not derive from this class in @" BASE_NAME);
1.84 paf 1638: YYERROR;
1639: }
1640: } else {
1.1 parser 1641: strcpy(PC.error, base_name.cstr());
1.160 moko 1642: strcat(PC.error, ": undefined class in @" BASE_NAME);
1.1 parser 1643: YYERROR;
1644: }
1645: } else {
1.160 moko 1646: strcpy(PC.error, "@" BASE_NAME " must contain sole name");
1.1 parser 1647: YYERROR;
1648: }
1.116 misha 1649: } else if(command==OPTIONS_CONTROL_METHOD_NAME) {
1.118 misha 1650: for(size_t i=0; i<strings_code->count(); i+=OPERATIONS_PER_OPVALUE) {
1.152 misha 1651: const String& option=LA2S(*strings_code, i)->trim(String::TRIM_END);
1.119 misha 1652: if(option==OPTION_ALL_VARS_LOCAL_NAME){
1653: PC.set_all_vars_local();
1.123 misha 1654: } else if(option==OPTION_PARTIAL_CLASS){
1655: if(PC.cclass_new){
1656: if(VStateless_class* existed=PC.get_existed_class(PC.cclass_new)){
1657: if(!PC.reuse_existed_class(existed)){
1658: strcpy(PC.error, "can't append methods to '");
1659: strncat(PC.error, PC.cclass_new->name().cstr(), MAX_STRING/2);
1660: strcat(PC.error, "' - the class wasn't marked as partial");
1661: YYERROR;
1662: }
1.119 misha 1663: } else {
1.149 misha 1664: // marks the new class as partial. we will be able to add methods here later.
1.123 misha 1665: PC.cclass_new->set_partial();
1.119 misha 1666: }
1.123 misha 1667: } else {
1.160 moko 1668: strcpy(PC.error, "'" OPTION_PARTIAL_CLASS "' option should be used straight after @" CLASS_NAME);
1.119 misha 1669: YYERROR;
1670: }
1.149 misha 1671: } else if(option==method_call_type_static){
1672: PC.set_methods_call_type(Method::CT_STATIC);
1673: } else if(option==method_call_type_dynamic){
1674: PC.set_methods_call_type(Method::CT_DYNAMIC);
1.118 misha 1675: } else {
1.119 misha 1676: strcpy(PC.error, "'");
1677: strncat(PC.error, option.cstr(), MAX_STRING/2);
1678: strcat(PC.error, "' invalid option. valid options are "
1.160 moko 1679: "'" OPTION_PARTIAL_CLASS "', '" OPTION_ALL_VARS_LOCAL_NAME "'"
1680: ", '" METHOD_CALL_TYPE_STATIC "' and '" METHOD_CALL_TYPE_DYNAMIC "'"
1.149 misha 1681: );
1.118 misha 1682: YYERROR;
1.116 misha 1683: }
1684: }
1.1 parser 1685: } else {
1686: strcpy(PC.error, "'");
1687: strncat(PC.error, command.cstr(), MAX_STRING/2);
1688: strcat(PC.error, "' invalid special name. valid names are "
1.160 moko 1689: "'" CLASS_NAME "', '" USE_CONTROL_METHOD_NAME "', '" BASE_NAME "' and '" OPTIONS_CONTROL_METHOD_NAME "'.");
1.1 parser 1690: YYERROR;
1691: }
1.158 misha 1692: }
1.163 ! moko 1693: #line 1694 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1694: break;
1695:
1696: case 13:
1.163 ! moko 1697: #line 267 "compile.y" /* yacc.c:1646 */
! 1698: { (yyval)=(yyvsp[-1]); P(*(yyval), *(yyvsp[0])); }
! 1699: #line 1700 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1700: break;
1701:
1702: case 17:
1.163 ! moko 1703: #line 271 "compile.y" /* yacc.c:1646 */
1.112 paf 1704: {
1.157 moko 1705: CLASS_ADD;
1.96 paf 1706: PC.explicit_result=false;
1.1 parser 1707:
1.163 ! moko 1708: YYSTYPE params_names_code=(yyvsp[-3]);
1.84 paf 1709: ArrayString* params_names=0;
1710: if(int size=params_names_code->count()) {
1711: params_names=new ArrayString;
1712: for(int i=0; i<size; i+=OPERATIONS_PER_OPVALUE)
1713: *params_names+=LA2S(*params_names_code, i);
1.1 parser 1714: }
1715:
1.163 ! moko 1716: YYSTYPE locals_names_code=(yyvsp[-2]);
1.84 paf 1717: ArrayString* locals_names=0;
1.116 misha 1718: bool all_vars_local=false;
1.84 paf 1719: if(int size=locals_names_code->count()) {
1720: locals_names=new ArrayString;
1.96 paf 1721: for(int i=0; i<size; i+=OPERATIONS_PER_OPVALUE) {
1722: const String* local_name=LA2S(*locals_names_code, i);
1723: if(*local_name==RESULT_VAR_NAME)
1724: PC.explicit_result=true;
1.119 misha 1725: else if(*local_name==OPTION_ALL_VARS_LOCAL_NAME)
1.116 misha 1726: all_vars_local=true;
1.96 paf 1727: else
1728: *locals_names+=local_name;
1729: }
1.1 parser 1730: }
1.124 misha 1731: if(!all_vars_local && PC.cclass && PC.cclass->is_vars_local())
1.116 misha 1732: all_vars_local=true;
1.1 parser 1733:
1.96 paf 1734: Method* method=new Method(
1.84 paf 1735: //name,
1.163 ! moko 1736: GetMethodCallType(PC, *(yyvsp[-4])),
1.1 parser 1737: 0, 0/*min,max numbered_params_count*/,
1738: params_names, locals_names,
1.116 misha 1739: 0/*to be filled later in next {} */, 0, all_vars_local);
1.114 misha 1740:
1.156 moko 1741: *reinterpret_cast<Method**>(&(yyval))=method;
1.158 misha 1742: }
1.163 ! moko 1743: #line 1744 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1744: break;
1745:
1.115 misha 1746: case 18:
1.163 ! moko 1747: #line 309 "compile.y" /* yacc.c:1646 */
1.115 misha 1748: {
1.163 ! moko 1749: Method* method=reinterpret_cast<Method*>((yyvsp[-1]));
1.124 misha 1750: // fill in the code
1.163 ! moko 1751: method->parser_code=(yyvsp[0]);
1.124 misha 1752:
1753: // register in class
1.163 ! moko 1754: const String& name=*LA2S(*(yyvsp[-6]));
1.144 misha 1755: PC.cclass->set_method(PC.alias_method(name), method);
1.158 misha 1756: }
1.163 ! moko 1757: #line 1758 "compile.tab.C" /* yacc.c:1646 */
1.115 misha 1758: break;
1759:
1760: case 21:
1.163 ! moko 1761: #line 320 "compile.y" /* yacc.c:1646 */
! 1762: {(yyval)=(yyvsp[-1]);}
! 1763: #line 1764 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1764: break;
1765:
1.115 misha 1766: case 25:
1.163 ! moko 1767: #line 322 "compile.y" /* yacc.c:1646 */
! 1768: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); }
! 1769: #line 1770 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1770: break;
1771:
1.115 misha 1772: case 31:
1.163 ! moko 1773: #line 330 "compile.y" /* yacc.c:1646 */
! 1774: { (yyval)=(yyvsp[-1]); P(*(yyval), *(yyvsp[0])); }
! 1775: #line 1776 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1776: break;
1777:
1.115 misha 1778: case 37:
1.163 ! moko 1779: #line 336 "compile.y" /* yacc.c:1646 */
1.112 paf 1780: {
1.156 moko 1781: (yyval)=N();
1.163 ! moko 1782: YYSTYPE code=(yyvsp[0]);
1.140 misha 1783: size_t count=code->count();
1.138 misha 1784:
1.128 misha 1785: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
1.140 misha 1786: if(
1787: count!=3
1.159 misha 1788: || !change_first(*code, OP::OP_VALUE__GET_ELEMENT, /*=>*/OP::OP_VALUE__GET_ELEMENT__WRITE)
1.140 misha 1789: )
1.131 misha 1790: #endif
1.140 misha 1791:
1.138 misha 1792: #ifdef OPTIMIZE_BYTECODE_GET_SELF_ELEMENT
1.140 misha 1793: if(
1794: count!=3
1.159 misha 1795: || !change_first(*code, OP::OP_WITH_SELF__VALUE__GET_ELEMENT, /*=>*/OP::OP_WITH_SELF__VALUE__GET_ELEMENT__WRITE)
1.140 misha 1796: )
1.138 misha 1797: #endif
1798:
1.132 misha 1799: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
1.140 misha 1800: if(
1801: count!=5
1.159 misha 1802: || !change_first(*code, OP::OP_GET_OBJECT_ELEMENT, /*=>*/OP::OP_GET_OBJECT_ELEMENT__WRITE)
1.140 misha 1803: )
1.128 misha 1804: #endif
1.132 misha 1805:
1806: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
1.140 misha 1807: if(
1808: count!=5
1.159 misha 1809: || !change_first(*code, OP::OP_GET_OBJECT_VAR_ELEMENT, /*=>*/OP::OP_GET_OBJECT_VAR_ELEMENT__WRITE)
1.140 misha 1810: )
1.131 misha 1811: #endif
1.159 misha 1812:
1813: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL
1814: if(
1815: !change(*code, count-1/* last */, OP::OP_GET_ELEMENT__SPECIAL, /*=>*/OP::OP_GET_ELEMENT__SPECIAL__WRITE)
1816: )
1817: #endif
1818:
1.140 misha 1819: {
1.159 misha 1820: change_or_append(*code, count-1 /* last */,
1821: OP::OP_GET_ELEMENT, /*=>*/OP::OP_GET_ELEMENT__WRITE,
1.140 misha 1822: /*or */OP::OP_WRITE_VALUE
1823: ); /* value=pop; wcontext.write(value) */
1.139 misha 1824: }
1.140 misha 1825:
1.156 moko 1826: P(*(yyval), *code);
1.158 misha 1827: }
1.163 ! moko 1828: #line 1829 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1829: break;
1830:
1.115 misha 1831: case 38:
1.163 ! moko 1832: #line 384 "compile.y" /* yacc.c:1646 */
! 1833: { (yyval)=(yyvsp[0]); }
! 1834: #line 1835 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1835: break;
1836:
1.115 misha 1837: case 41:
1.163 ! moko 1838: #line 386 "compile.y" /* yacc.c:1646 */
! 1839: { (yyval)=(yyvsp[-1]); }
! 1840: #line 1841 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1841: break;
1842:
1.115 misha 1843: case 44:
1.163 ! moko 1844: #line 390 "compile.y" /* yacc.c:1646 */
1.112 paf 1845: {
1.156 moko 1846: (yyval)=N();
1.163 ! moko 1847: YYSTYPE diving_code=(yyvsp[0]);
1.132 misha 1848: size_t count=diving_code->count();
1.140 misha 1849:
1.156 moko 1850: if(maybe_make_self(*(yyval), *diving_code, count)) {
1.140 misha 1851: // $self.
1852: } else
1.132 misha 1853:
1854: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
1.156 moko 1855: if(maybe_make_get_object_element(*(yyval), *diving_code, count)){
1.138 misha 1856: // optimization for $object.field + ^object.method[
1.140 misha 1857: } else
1.131 misha 1858: #endif
1.132 misha 1859:
1860: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
1.156 moko 1861: if(maybe_make_get_object_var_element(*(yyval), *diving_code, count)){
1.138 misha 1862: // optimization for $object.$var
1.140 misha 1863: } else
1.131 misha 1864: #endif
1.132 misha 1865:
1866: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
1.141 misha 1867: if(
1868: count>=4
1869: && (*diving_code)[0].code==OP::OP_VALUE
1870: && (*diving_code)[3].code==OP::OP_GET_ELEMENT
1871: ){
1872: // optimization
1.156 moko 1873: O(*(yyval),
1.140 misha 1874: (PC.in_call_value && count==4)
1.132 misha 1875: ? OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR // ^object[ : OP_VALUE+origin+string+OP_GET_ELEMENT => OP_VALUE__GET_ELEMENT_OR_OPERATOR+origin+string
1876: : OP::OP_VALUE__GET_ELEMENT // $object : OP_VALUE+origin+string+OP_GET_ELEMENT => OP_VALUE__GET_ELEMENT+origin+string
1877: );
1.156 moko 1878: P(*(yyval), *diving_code, 1/*offset*/, 2/*limit*/); // copy origin+value
1.140 misha 1879: if(count>4)
1.156 moko 1880: P(*(yyval), *diving_code, 4); // copy tail
1.132 misha 1881: } else {
1.156 moko 1882: O(*(yyval), OP::OP_WITH_READ); /* stack: starting context */
1883: P(*(yyval), *diving_code);
1.132 misha 1884: }
1.126 misha 1885: #else
1.140 misha 1886: {
1.156 moko 1887: O(*(yyval), OP::OP_WITH_READ); /* stack: starting context */
1.37 paf 1888:
1.131 misha 1889: // ^if OP_ELEMENT => ^if OP_ELEMENT_OR_OPERATOR
1890: // optimized OP_VALUE+origin+string+OP_GET_ELEMENT. => OP_VALUE+origin+string+OP_GET_ELEMENT_OR_OPERATOR.
1.132 misha 1891: if(PC.in_call_value && count==4)
1892: diving_code->put(count-1, OP::OP_GET_ELEMENT_OR_OPERATOR);
1.156 moko 1893: P(*(yyval), *diving_code);
1.132 misha 1894: }
1.126 misha 1895: #endif
1.1 parser 1896: /* diving code; stack: current context */
1.158 misha 1897: }
1.163 ! moko 1898: #line 1899 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1899: break;
1900:
1.115 misha 1901: case 45:
1.163 ! moko 1902: #line 443 "compile.y" /* yacc.c:1646 */
! 1903: { (yyval)=(yyvsp[-1]); P(*(yyval), *(yyvsp[0])); }
! 1904: #line 1905 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1905: break;
1906:
1.115 misha 1907: case 47:
1.163 ! moko 1908: #line 444 "compile.y" /* yacc.c:1646 */
! 1909: { (yyval)=(yyvsp[-1]); P(*(yyval), *(yyvsp[0])); }
! 1910: #line 1911 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1911: break;
1912:
1.115 misha 1913: case 48:
1.163 ! moko 1914: #line 448 "compile.y" /* yacc.c:1646 */
1.112 paf 1915: {
1.156 moko 1916: (yyval)=N();
1.137 misha 1917: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
1.163 ! moko 1918: if(maybe_optimize_construct(*(yyval), *(yyvsp[-1]), *(yyvsp[0]))){
1.139 misha 1919: // $a(expr), $.a(expr), $a[value], $.a[value], $self.a[value], $self.a(expr)
1.134 misha 1920: } else
1921: #endif
1922: {
1.163 ! moko 1923: P(*(yyval), *(yyvsp[-1])); /* stack: context,name */
! 1924: P(*(yyval), *(yyvsp[0])); /* stack: context,name,constructor_value */
1.134 misha 1925: }
1.158 misha 1926: }
1.163 ! moko 1927: #line 1928 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1928: break;
1929:
1.115 misha 1930: case 52:
1.163 ! moko 1931: #line 464 "compile.y" /* yacc.c:1646 */
1.112 paf 1932: {
1.156 moko 1933: (yyval)=N();
1.163 ! moko 1934: YYSTYPE diving_code=(yyvsp[0]);
1.140 misha 1935: size_t count=diving_code->count();
1936:
1.156 moko 1937: if(maybe_make_self(*(yyval), *diving_code, count)) {
1.140 misha 1938: // $self.
1939: } else
1940: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
1941: if(
1942: count>=4
1943: && (*diving_code)[0].code==OP::OP_VALUE
1944: && (*diving_code)[3].code==OP::OP_GET_ELEMENT
1945: ){
1.156 moko 1946: O(*(yyval), OP::OP_WITH_ROOT__VALUE__GET_ELEMENT);
1947: P(*(yyval), *diving_code, 1/*offset*/, 2/*limit*/); // copy origin+value
1.140 misha 1948: if(count>4)
1.156 moko 1949: P(*(yyval), *diving_code, 4); // tail
1.140 misha 1950: } else
1951: #endif
1952: {
1.156 moko 1953: O(*(yyval), OP::OP_WITH_ROOT); /* stack: starting context */
1954: P(*(yyval), *diving_code);
1.1 parser 1955: }
1956: /* diving code; stack: current context */
1.158 misha 1957: }
1.163 ! moko 1958: #line 1959 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1959: break;
1960:
1.115 misha 1961: case 53:
1.163 ! moko 1962: #line 490 "compile.y" /* yacc.c:1646 */
1.112 paf 1963: {
1.156 moko 1964: (yyval)=N();
1965: O(*(yyval), OP::OP_WITH_WRITE); /* stack: starting context */
1.163 ! moko 1966: P(*(yyval), *(yyvsp[0])); /* diving code; stack: context,name */
1.158 misha 1967: }
1.163 ! moko 1968: #line 1969 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1969: break;
1970:
1.115 misha 1971: case 54:
1.163 ! moko 1972: #line 495 "compile.y" /* yacc.c:1646 */
! 1973: { (yyval)=(yyvsp[-1]); P(*(yyval), *(yyvsp[0])); }
! 1974: #line 1975 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1975: break;
1976:
1.115 misha 1977: case 58:
1.163 ! moko 1978: #line 502 "compile.y" /* yacc.c:1646 */
1.112 paf 1979: {
1.100 paf 1980: // allow $result_or_other_variable[ letters here any time ]
1.156 moko 1981: *reinterpret_cast<bool*>(&(yyval))=PC.explicit_result; PC.explicit_result=false;
1.158 misha 1982: }
1.163 ! moko 1983: #line 1984 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1984: break;
1985:
1.115 misha 1986: case 59:
1.163 ! moko 1987: #line 505 "compile.y" /* yacc.c:1646 */
1.112 paf 1988: {
1.163 ! moko 1989: PC.explicit_result=*reinterpret_cast<bool*>(&(yyvsp[-1]));
1.158 misha 1990: }
1.163 ! moko 1991: #line 1992 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 1992: break;
1993:
1.115 misha 1994: case 60:
1.163 ! moko 1995: #line 507 "compile.y" /* yacc.c:1646 */
1.112 paf 1996: {
1.1 parser 1997: // stack: context, name
1.163 ! moko 1998: (yyval)=(yyvsp[-2]); // stack: context, name, value
1.156 moko 1999: O(*(yyval), OP::OP_CONSTRUCT_VALUE); /* value=pop; name=pop; context=pop; construct(context,name,value) */
1.158 misha 2000: }
1.163 ! moko 2001: #line 2002 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2002: break;
2003:
1.115 misha 2004: case 61:
1.163 ! moko 2005: #line 513 "compile.y" /* yacc.c:1646 */
1.112 paf 2006: {
1.156 moko 2007: (yyval)=N();
2008: O(*(yyval), OP::OP_PREPARE_TO_EXPRESSION);
1.1 parser 2009: // stack: context, name
1.163 ! moko 2010: P(*(yyval), *(yyvsp[-1])); // stack: context, name, value
1.156 moko 2011: O(*(yyval), OP::OP_CONSTRUCT_EXPR); /* value=pop->as_expr_result; name=pop; context=pop; construct(context,name,value) */
1.158 misha 2012: }
1.163 ! moko 2013: #line 2014 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2014: break;
2015:
1.115 misha 2016: case 62:
1.163 ! moko 2017: #line 521 "compile.y" /* yacc.c:1646 */
1.112 paf 2018: {
1.1 parser 2019: // stack: context, name
1.156 moko 2020: (yyval)=N();
1.163 ! moko 2021: OA(*(yyval), OP::OP_CURLY_CODE__CONSTRUCT, (yyvsp[-1])); /* code=pop; name=pop; context=pop; construct(context,name,junction(code)) */
1.158 misha 2022: }
1.163 ! moko 2023: #line 2024 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2024: break;
2025:
1.115 misha 2026: case 66:
1.163 ! moko 2027: #line 532 "compile.y" /* yacc.c:1646 */
1.112 paf 2028: {
1.156 moko 2029: (yyval)=N();
1.163 ! moko 2030: OA(*(yyval), OP::OP_OBJECT_POOL, (yyvsp[0])); /* stack: empty write context */
1.47 paf 2031: /* some code that writes to that context */
2032: /* context=pop; stack: context.value() */
1.158 misha 2033: }
1.163 ! moko 2034: #line 2035 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2035: break;
2036:
1.115 misha 2037: case 69:
1.163 ! moko 2038: #line 539 "compile.y" /* yacc.c:1646 */
! 2039: { (yyval)=(yyvsp[-1]); P(*(yyval), *(yyvsp[0])); }
! 2040: #line 2041 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2041: break;
2042:
1.115 misha 2043: case 70:
1.163 ! moko 2044: #line 543 "compile.y" /* yacc.c:1646 */
1.112 paf 2045: {
1.163 ! moko 2046: size_t count=(yyvsp[0])->count();
1.131 misha 2047: #ifdef OPTIMIZE_BYTECODE_CUT_REM_OPERATOR
1.159 misha 2048: if(count)
1.131 misha 2049: #endif
2050: {
1.163 ! moko 2051: (yyval)=(yyvsp[0]); /* stack: value */
1.159 misha 2052: if(!change_first(*(yyval), OP::OP_CONSTRUCT_OBJECT, /*=>*/OP::OP_CONSTRUCT_OBJECT__WRITE))
2053: change_or_append(*(yyval), count-2 /* second last */,
2054: OP::OP_CALL, /*=>*/ OP::OP_CALL__WRITE,
1.142 misha 2055: /*or */OP::OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */
1.131 misha 2056: }
1.158 misha 2057: }
1.163 ! moko 2058: #line 2059 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2059: break;
2060:
1.115 misha 2061: case 71:
1.163 ! moko 2062: #line 556 "compile.y" /* yacc.c:1646 */
1.112 paf 2063: {
1.39 paf 2064: PC.in_call_value=true;
1.158 misha 2065: }
1.163 ! moko 2066: #line 2067 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2067: break;
2068:
1.115 misha 2069: case 72:
1.163 ! moko 2070: #line 559 "compile.y" /* yacc.c:1646 */
1.112 paf 2071: {
1.39 paf 2072: PC.in_call_value=false;
1.158 misha 2073: }
1.163 ! moko 2074: #line 2075 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2075: break;
2076:
1.115 misha 2077: case 73:
1.163 ! moko 2078: #line 562 "compile.y" /* yacc.c:1646 */
1.112 paf 2079: { /* ^field.$method{vasya} */
1.131 misha 2080: #ifdef OPTIMIZE_BYTECODE_CUT_REM_OPERATOR
1.135 misha 2081: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
1.163 ! moko 2082: const String* operator_name=LA2S(*(yyvsp[-3]), 0, OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR);
1.135 misha 2083: #else
1.163 ! moko 2084: const String* operator_name=LA2S(*(yyvsp[-3]), 1);
1.135 misha 2085: #endif
1.142 misha 2086: if(operator_name && *operator_name==REM_OPERATOR_NAME){
1.156 moko 2087: (yyval)=N();
1.131 misha 2088: } else
2089: #endif
2090: {
1.163 ! moko 2091: YYSTYPE params_code=(yyvsp[-1]);
1.131 misha 2092: if(params_code->count()==3) { // probably [] case. [OP::OP_VALUE+origin+Void]
2093: if(Value* value=LA2V(*params_code)) // it is OP_VALUE+origin+value?
1.153 moko 2094: if(const String * string=value->get_string())
2095: if(string->is_empty()) // value is empty string?
2096: params_code=0; // ^zzz[] case. don't append lone empty param.
1.131 misha 2097: }
2098: /* stack: context, method_junction */
1.142 misha 2099:
1.163 ! moko 2100: YYSTYPE var_code=(yyvsp[-3]);
1.142 misha 2101: if(
2102: var_code->count()==8
2103: && (*var_code)[0].code==OP::OP_VALUE__GET_CLASS
2104: && (*var_code)[3].code==OP::OP_PREPARE_TO_CONSTRUCT_OBJECT
2105: && (*var_code)[4].code==OP::OP_VALUE
2106: && (*var_code)[7].code==OP::OP_GET_ELEMENT
2107: ){
1.159 misha 2108: (yyval)=N();
1.156 moko 2109: O(*(yyval), OP::OP_CONSTRUCT_OBJECT);
2110: P(*(yyval), *var_code, 1/*offset*/, 2/*limit*/); // class name
2111: P(*(yyval), *var_code, 5/*offset*/, 2/*limit*/); // constructor name
2112: OA(*(yyval), params_code);
1.142 misha 2113: } else
2114: {
1.156 moko 2115: (yyval)=var_code; /* with_xxx,diving code; stack: context,method_junction */
2116: OA(*(yyval), OP::OP_CALL, params_code); // method_frame=make frame(pop junction); ncontext=pop; call(ncontext,method_frame) stack: value
1.142 misha 2117: }
1.131 misha 2118: }
1.158 misha 2119: }
1.163 ! moko 2120: #line 2121 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2121: break;
2122:
1.115 misha 2123: case 76:
1.163 ! moko 2124: #line 606 "compile.y" /* yacc.c:1646 */
! 2125: { (yyval)=(yyvsp[-1]); P(*(yyval), *(yyvsp[0])); }
! 2126: #line 2127 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2127: break;
2128:
1.115 misha 2129: case 80:
1.163 ! moko 2130: #line 612 "compile.y" /* yacc.c:1646 */
1.112 paf 2131: {
1.100 paf 2132: // allow ^call[ letters here any time ]
1.156 moko 2133: *reinterpret_cast<bool*>(&(yyval))=PC.explicit_result; PC.explicit_result=false;
1.158 misha 2134: }
1.163 ! moko 2135: #line 2136 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2136: break;
2137:
1.115 misha 2138: case 81:
1.163 ! moko 2139: #line 615 "compile.y" /* yacc.c:1646 */
1.112 paf 2140: {
1.163 ! moko 2141: PC.explicit_result=*reinterpret_cast<bool*>(&(yyvsp[-1]));
1.158 misha 2142: }
1.163 ! moko 2143: #line 2144 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2144: break;
2145:
1.115 misha 2146: case 82:
1.163 ! moko 2147: #line 617 "compile.y" /* yacc.c:1646 */
! 2148: {(yyval)=(yyvsp[-2]);}
! 2149: #line 2150 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2150: break;
2151:
1.115 misha 2152: case 83:
1.163 ! moko 2153: #line 618 "compile.y" /* yacc.c:1646 */
! 2154: {(yyval)=(yyvsp[-1]);}
! 2155: #line 2156 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2156: break;
2157:
1.115 misha 2158: case 84:
1.163 ! moko 2159: #line 619 "compile.y" /* yacc.c:1646 */
! 2160: {(yyval)=(yyvsp[-1]);}
! 2161: #line 2162 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2162: break;
2163:
1.115 misha 2164: case 86:
1.163 ! moko 2165: #line 622 "compile.y" /* yacc.c:1646 */
! 2166: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); }
! 2167: #line 2168 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2168: break;
2169:
1.115 misha 2170: case 88:
1.163 ! moko 2171: #line 626 "compile.y" /* yacc.c:1646 */
! 2172: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); }
! 2173: #line 2174 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2174: break;
2175:
1.115 misha 2176: case 90:
1.163 ! moko 2177: #line 630 "compile.y" /* yacc.c:1646 */
! 2178: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); }
! 2179: #line 2180 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2180: break;
2181:
1.115 misha 2182: case 91:
1.163 ! moko 2183: #line 632 "compile.y" /* yacc.c:1646 */
1.112 paf 2184: {
1.163 ! moko 2185: (yyval)=(yyvsp[0]);
1.158 misha 2186: }
1.163 ! moko 2187: #line 2188 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2188: break;
2189:
1.115 misha 2190: case 92:
1.163 ! moko 2191: #line 635 "compile.y" /* yacc.c:1646 */
1.112 paf 2192: {
1.163 ! moko 2193: YYSTYPE expr_code=(yyvsp[0]);
1.106 paf 2194: if(expr_code->count()==3
1.127 misha 2195: && (*expr_code)[0].code==OP::OP_VALUE) { // optimizing (double/bool/incidently 'string' too) case. [OP::OP_VALUE+origin+Double]. no evaluating
1.156 moko 2196: (yyval)=expr_code;
1.104 paf 2197: } else {
1.131 misha 2198: YYSTYPE code=N();
1.122 misha 2199: O(*code, OP::OP_PREPARE_TO_EXPRESSION);
1.104 paf 2200: P(*code, *expr_code);
1.122 misha 2201: O(*code, OP::OP_WRITE_EXPR_RESULT);
1.156 moko 2202: (yyval)=N();
2203: OA(*(yyval), OP::OP_EXPR_CODE__STORE_PARAM, code);
1.104 paf 2204: }
1.158 misha 2205: }
1.163 ! moko 2206: #line 2207 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2207: break;
2208:
1.115 misha 2209: case 93:
1.163 ! moko 2210: #line 649 "compile.y" /* yacc.c:1646 */
1.112 paf 2211: {
1.156 moko 2212: (yyval)=N();
1.163 ! moko 2213: OA(*(yyval), OP::OP_CURLY_CODE__STORE_PARAM, (yyvsp[0]));
1.158 misha 2214: }
1.163 ! moko 2215: #line 2216 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2216: break;
2217:
1.115 misha 2218: case 98:
1.163 ! moko 2219: #line 661 "compile.y" /* yacc.c:1646 */
! 2220: { (yyval)=(yyvsp[-1]); P(*(yyval), *(yyvsp[0])); }
! 2221: #line 2222 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2222: break;
2223:
1.115 misha 2224: case 100:
1.163 ! moko 2225: #line 663 "compile.y" /* yacc.c:1646 */
! 2226: { (yyval)=(yyvsp[-1]); P(*(yyval), *(yyvsp[0])); }
! 2227: #line 2228 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2228: break;
2229:
1.115 misha 2230: case 102:
1.163 ! moko 2231: #line 665 "compile.y" /* yacc.c:1646 */
1.112 paf 2232: {
1.33 paf 2233: // we know that name_advance1 not called from ^xxx context
2234: // so we'll not check for operator call possibility as we do in name_advance2
2235:
1.1 parser 2236: /* stack: context */
1.163 ! moko 2237: (yyval)=(yyvsp[0]); /* stack: context,name */
1.159 misha 2238: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL
2239: O(*(yyval), is_special_element(*(yyval)) ? OP::OP_GET_ELEMENT__SPECIAL : OP::OP_GET_ELEMENT);
2240: #else
1.156 moko 2241: O(*(yyval), OP::OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */
1.159 misha 2242: #endif
1.158 misha 2243: }
1.163 ! moko 2244: #line 2245 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2245: break;
2246:
1.115 misha 2247: case 103:
1.163 ! moko 2248: #line 677 "compile.y" /* yacc.c:1646 */
1.112 paf 2249: {
1.1 parser 2250: /* stack: context */
1.163 ! moko 2251: (yyval)=(yyvsp[0]); /* stack: context,name */
1.159 misha 2252: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL
2253: O(*(yyval), is_special_element(*(yyval)) ? OP::OP_GET_ELEMENT__SPECIAL : OP::OP_GET_ELEMENT);
2254: #else
1.156 moko 2255: O(*(yyval), OP::OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */
1.159 misha 2256: #endif
1.158 misha 2257: }
1.163 ! moko 2258: #line 2259 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2259: break;
2260:
1.115 misha 2261: case 109:
1.163 ! moko 2262: #line 694 "compile.y" /* yacc.c:1646 */
1.112 paf 2263: {
1.163 ! moko 2264: (yyval)=(yyvsp[0]);
1.156 moko 2265: O(*(yyval), OP::OP_GET_ELEMENT);
1.158 misha 2266: }
1.163 ! moko 2267: #line 2268 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2268: break;
2269:
1.115 misha 2270: case 110:
1.163 ! moko 2271: #line 698 "compile.y" /* yacc.c:1646 */
1.112 paf 2272: {
1.131 misha 2273: YYSTYPE code;
1.47 paf 2274: {
1.163 ! moko 2275: change_string_literal_to_write_string_literal(*(code=(yyvsp[-1])));
! 2276: P(*code, *(yyvsp[0]));
1.47 paf 2277: }
1.156 moko 2278: (yyval)=N();
2279: OA(*(yyval), OP::OP_STRING_POOL, code);
1.158 misha 2280: }
1.163 ! moko 2281: #line 2282 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2282: break;
2283:
1.115 misha 2284: case 111:
1.163 ! moko 2285: #line 707 "compile.y" /* yacc.c:1646 */
1.112 paf 2286: {
1.100 paf 2287: // allow $result_or_other_variable[ letters here any time ]
1.156 moko 2288: *reinterpret_cast<bool*>(&(yyval))=PC.explicit_result; PC.explicit_result=false;
1.158 misha 2289: }
1.163 ! moko 2290: #line 2291 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2291: break;
2292:
1.115 misha 2293: case 112:
1.163 ! moko 2294: #line 710 "compile.y" /* yacc.c:1646 */
1.112 paf 2295: {
1.163 ! moko 2296: PC.explicit_result=*reinterpret_cast<bool*>(&(yyvsp[-1]));
1.158 misha 2297: }
1.163 ! moko 2298: #line 2299 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2299: break;
2300:
1.115 misha 2301: case 113:
1.163 ! moko 2302: #line 712 "compile.y" /* yacc.c:1646 */
1.112 paf 2303: {
1.156 moko 2304: (yyval)=N();
1.159 misha 2305: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL
1.163 ! moko 2306: if(!maybe_append_simple_diving_code(*(yyval), *(yyvsp[-2])))
1.159 misha 2307: #endif
2308: {
1.163 ! moko 2309: OA(*(yyval), OP::OP_OBJECT_POOL, (yyvsp[-2])); /* stack: empty write context */
1.47 paf 2310: /* some code that writes to that context */
2311: /* context=pop; stack: context.value() */
1.159 misha 2312: }
1.158 misha 2313: }
1.163 ! moko 2314: #line 2315 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2315: break;
2316:
1.115 misha 2317: case 114:
1.163 ! moko 2318: #line 723 "compile.y" /* yacc.c:1646 */
1.112 paf 2319: {
1.156 moko 2320: (yyval)=N();
2321: O(*(yyval), OP::OP_WITH_READ);
1.163 ! moko 2322: P(*(yyval), *(yyvsp[0]));
1.158 misha 2323: }
1.163 ! moko 2324: #line 2325 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2325: break;
2326:
1.115 misha 2327: case 116:
1.163 ! moko 2328: #line 728 "compile.y" /* yacc.c:1646 */
! 2329: { (yyval)=(yyvsp[-1]); P(*(yyval), *(yyvsp[0])); }
! 2330: #line 2331 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2331: break;
2332:
1.115 misha 2333: case 117:
1.163 ! moko 2334: #line 729 "compile.y" /* yacc.c:1646 */
1.112 paf 2335: {
1.163 ! moko 2336: (yyval)=(yyvsp[0]);
1.156 moko 2337: O(*(yyval), OP::OP_GET_ELEMENT__WRITE);
1.158 misha 2338: }
1.163 ! moko 2339: #line 2340 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2340: break;
2341:
1.115 misha 2342: case 120:
1.163 ! moko 2343: #line 738 "compile.y" /* yacc.c:1646 */
1.112 paf 2344: {
1.163 ! moko 2345: (yyval)=(yyvsp[-1]); // stack: class name string
1.156 moko 2346: if(*LA2S(*(yyval)) == BASE_NAME) { // pseudo BASE class
1.84 paf 2347: if(VStateless_class* base=PC.cclass->base_class()) {
1.156 moko 2348: change_string_literal_value(*(yyval), base->name());
1.61 paf 2349: } else {
2350: strcpy(PC.error, "no base class declared");
2351: YYERROR;
2352: }
2353: }
1.131 misha 2354: // optimized OP_VALUE+origin+string+OP_GET_CLASS => OP_VALUE__GET_CLASS+origin+string
1.159 misha 2355: change_first(*(yyval), OP::OP_VALUE, OP::OP_VALUE__GET_CLASS);
1.158 misha 2356: }
1.163 ! moko 2357: #line 2358 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2358: break;
2359:
1.115 misha 2360: case 121:
1.163 ! moko 2361: #line 751 "compile.y" /* yacc.c:1646 */
1.112 paf 2362: {
1.163 ! moko 2363: (yyval)=(yyvsp[-1]);
1.39 paf 2364: if(!PC.in_call_value) {
1.1 parser 2365: strcpy(PC.error, ":: not allowed here");
2366: YYERROR;
2367: }
1.156 moko 2368: O(*(yyval), OP::OP_PREPARE_TO_CONSTRUCT_OBJECT);
1.158 misha 2369: }
1.163 ! moko 2370: #line 2371 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2371: break;
2372:
1.115 misha 2373: case 128:
1.163 ! moko 2374: #line 770 "compile.y" /* yacc.c:1646 */
! 2375: { (yyval) = (yyvsp[-1]); }
! 2376: #line 2377 "compile.tab.C" /* yacc.c:1646 */
1.114 misha 2377: break;
2378:
1.115 misha 2379: case 129:
1.163 ! moko 2380: #line 771 "compile.y" /* yacc.c:1646 */
! 2381: { (yyval) = (yyvsp[-1]); }
! 2382: #line 2383 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2383: break;
2384:
1.115 misha 2385: case 130:
1.163 ! moko 2386: #line 772 "compile.y" /* yacc.c:1646 */
! 2387: { (yyval) = (yyvsp[-1]); }
! 2388: #line 2389 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2389: break;
2390:
1.115 misha 2391: case 131:
1.163 ! moko 2392: #line 774 "compile.y" /* yacc.c:1646 */
! 2393: { (yyval)=(yyvsp[0]); O(*(yyval), OP::OP_NEG); }
! 2394: #line 2395 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2395: break;
2396:
1.115 misha 2397: case 132:
1.163 ! moko 2398: #line 775 "compile.y" /* yacc.c:1646 */
! 2399: { (yyval)=(yyvsp[0]); }
! 2400: #line 2401 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2401: break;
2402:
1.115 misha 2403: case 133:
1.163 ! moko 2404: #line 776 "compile.y" /* yacc.c:1646 */
! 2405: { (yyval)=(yyvsp[0]); O(*(yyval), OP::OP_INV); }
! 2406: #line 2407 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2407: break;
2408:
1.115 misha 2409: case 134:
1.163 ! moko 2410: #line 777 "compile.y" /* yacc.c:1646 */
! 2411: { (yyval)=(yyvsp[0]); O(*(yyval), OP::OP_NOT); }
! 2412: #line 2413 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2413: break;
2414:
1.115 misha 2415: case 135:
1.163 ! moko 2416: #line 778 "compile.y" /* yacc.c:1646 */
! 2417: { (yyval)=(yyvsp[0]); O(*(yyval), OP::OP_DEF); }
! 2418: #line 2419 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2419: break;
2420:
1.115 misha 2421: case 136:
1.163 ! moko 2422: #line 779 "compile.y" /* yacc.c:1646 */
! 2423: { (yyval)=(yyvsp[0]); O(*(yyval), OP::OP_IN); }
! 2424: #line 2425 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2425: break;
2426:
1.115 misha 2427: case 137:
1.163 ! moko 2428: #line 780 "compile.y" /* yacc.c:1646 */
! 2429: { (yyval)=(yyvsp[0]); O(*(yyval), OP::OP_FEXISTS); }
! 2430: #line 2431 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2431: break;
2432:
1.115 misha 2433: case 138:
1.163 ! moko 2434: #line 781 "compile.y" /* yacc.c:1646 */
! 2435: { (yyval)=(yyvsp[0]); O(*(yyval), OP::OP_DEXISTS); }
! 2436: #line 2437 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2437: break;
2438:
1.115 misha 2439: case 139:
1.163 ! moko 2440: #line 783 "compile.y" /* yacc.c:1646 */
! 2441: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_SUB); }
! 2442: #line 2443 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2443: break;
2444:
1.115 misha 2445: case 140:
1.163 ! moko 2446: #line 784 "compile.y" /* yacc.c:1646 */
! 2447: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_ADD); }
! 2448: #line 2449 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2449: break;
2450:
1.115 misha 2451: case 141:
1.163 ! moko 2452: #line 785 "compile.y" /* yacc.c:1646 */
! 2453: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_MUL); }
! 2454: #line 2455 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2455: break;
2456:
1.115 misha 2457: case 142:
1.163 ! moko 2458: #line 786 "compile.y" /* yacc.c:1646 */
! 2459: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_DIV); }
! 2460: #line 2461 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2461: break;
2462:
1.115 misha 2463: case 143:
1.163 ! moko 2464: #line 787 "compile.y" /* yacc.c:1646 */
! 2465: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_MOD); }
! 2466: #line 2467 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2467: break;
2468:
1.115 misha 2469: case 144:
1.163 ! moko 2470: #line 788 "compile.y" /* yacc.c:1646 */
! 2471: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_INTDIV); }
! 2472: #line 2473 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2473: break;
2474:
1.115 misha 2475: case 145:
1.163 ! moko 2476: #line 789 "compile.y" /* yacc.c:1646 */
! 2477: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_BIN_SL); }
! 2478: #line 2479 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2479: break;
2480:
1.115 misha 2481: case 146:
1.163 ! moko 2482: #line 790 "compile.y" /* yacc.c:1646 */
! 2483: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_BIN_SR); }
! 2484: #line 2485 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2485: break;
2486:
1.115 misha 2487: case 147:
1.163 ! moko 2488: #line 791 "compile.y" /* yacc.c:1646 */
! 2489: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_BIN_AND); }
! 2490: #line 2491 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2491: break;
2492:
1.115 misha 2493: case 148:
1.163 ! moko 2494: #line 792 "compile.y" /* yacc.c:1646 */
! 2495: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_BIN_OR); }
! 2496: #line 2497 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2497: break;
2498:
1.115 misha 2499: case 149:
1.163 ! moko 2500: #line 793 "compile.y" /* yacc.c:1646 */
! 2501: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_BIN_XOR); }
! 2502: #line 2503 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2503: break;
2504:
1.115 misha 2505: case 150:
1.163 ! moko 2506: #line 794 "compile.y" /* yacc.c:1646 */
! 2507: { (yyval)=(yyvsp[-2]); OA(*(yyval), OP::OP_NESTED_CODE, (yyvsp[0])); O(*(yyval), OP::OP_LOG_AND); }
! 2508: #line 2509 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2509: break;
2510:
1.115 misha 2511: case 151:
1.163 ! moko 2512: #line 795 "compile.y" /* yacc.c:1646 */
! 2513: { (yyval)=(yyvsp[-2]); OA(*(yyval), OP::OP_NESTED_CODE, (yyvsp[0])); O(*(yyval), OP::OP_LOG_OR); }
! 2514: #line 2515 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2515: break;
2516:
1.115 misha 2517: case 152:
1.163 ! moko 2518: #line 796 "compile.y" /* yacc.c:1646 */
! 2519: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_LOG_XOR); }
! 2520: #line 2521 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2521: break;
2522:
1.115 misha 2523: case 153:
1.163 ! moko 2524: #line 797 "compile.y" /* yacc.c:1646 */
! 2525: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_NUM_LT); }
! 2526: #line 2527 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2527: break;
2528:
1.115 misha 2529: case 154:
1.163 ! moko 2530: #line 798 "compile.y" /* yacc.c:1646 */
! 2531: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_NUM_GT); }
! 2532: #line 2533 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2533: break;
2534:
1.115 misha 2535: case 155:
1.163 ! moko 2536: #line 799 "compile.y" /* yacc.c:1646 */
! 2537: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_NUM_LE); }
! 2538: #line 2539 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2539: break;
2540:
1.115 misha 2541: case 156:
1.163 ! moko 2542: #line 800 "compile.y" /* yacc.c:1646 */
! 2543: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_NUM_GE); }
! 2544: #line 2545 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2545: break;
2546:
1.115 misha 2547: case 157:
1.163 ! moko 2548: #line 801 "compile.y" /* yacc.c:1646 */
! 2549: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_NUM_EQ); }
! 2550: #line 2551 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2551: break;
2552:
1.115 misha 2553: case 158:
1.163 ! moko 2554: #line 802 "compile.y" /* yacc.c:1646 */
! 2555: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_NUM_NE); }
! 2556: #line 2557 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2557: break;
2558:
1.115 misha 2559: case 159:
1.163 ! moko 2560: #line 803 "compile.y" /* yacc.c:1646 */
! 2561: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_STR_LT); }
! 2562: #line 2563 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2563: break;
2564:
1.115 misha 2565: case 160:
1.163 ! moko 2566: #line 804 "compile.y" /* yacc.c:1646 */
! 2567: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_STR_GT); }
! 2568: #line 2569 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2569: break;
2570:
1.115 misha 2571: case 161:
1.163 ! moko 2572: #line 805 "compile.y" /* yacc.c:1646 */
! 2573: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_STR_LE); }
! 2574: #line 2575 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2575: break;
2576:
1.115 misha 2577: case 162:
1.163 ! moko 2578: #line 806 "compile.y" /* yacc.c:1646 */
! 2579: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_STR_GE); }
! 2580: #line 2581 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2581: break;
2582:
1.115 misha 2583: case 163:
1.163 ! moko 2584: #line 807 "compile.y" /* yacc.c:1646 */
! 2585: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_STR_EQ); }
! 2586: #line 2587 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2587: break;
2588:
1.115 misha 2589: case 164:
1.163 ! moko 2590: #line 808 "compile.y" /* yacc.c:1646 */
! 2591: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_STR_NE); }
! 2592: #line 2593 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2593: break;
2594:
1.115 misha 2595: case 165:
1.163 ! moko 2596: #line 809 "compile.y" /* yacc.c:1646 */
! 2597: { (yyval)=(yyvsp[-2]); P(*(yyval), *(yyvsp[0])); O(*(yyval), OP::OP_IS); }
! 2598: #line 2599 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2599: break;
2600:
1.115 misha 2601: case 166:
1.163 ! moko 2602: #line 812 "compile.y" /* yacc.c:1646 */
1.112 paf 2603: {
1.131 misha 2604: // optimized OP_STRING => OP_VALUE for doubles
1.163 ! moko 2605: maybe_change_string_literal_to_double_literal(*((yyval)=(yyvsp[0])));
1.158 misha 2606: }
1.163 ! moko 2607: #line 2608 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2608: break;
2609:
1.115 misha 2610: case 167:
1.163 ! moko 2611: #line 817 "compile.y" /* yacc.c:1646 */
1.112 paf 2612: {
1.131 misha 2613: #ifdef OPTIMIZE_BYTECODE_STRING_POOL
2614: // it brakes ^if(" 09 "){...}
1.163 ! moko 2615: YYSTYPE code=(yyvsp[0]);
1.156 moko 2616: (yyval)=N();
1.159 misha 2617: if(code->count()==3 && change_first(*code, OP::OP_STRING__WRITE, OP::OP_VALUE)){
1.131 misha 2618: // optimized OP_STRING__WRITE+origin+value => OP_VALUE+origin+value without starting OP_STRING_POOL
1.156 moko 2619: P(*(yyval), *code);
1.131 misha 2620: } else {
1.156 moko 2621: OA(*(yyval), OP::OP_STRING_POOL, code); /* stack: empty write context */
1.131 misha 2622: }
2623: #else
1.156 moko 2624: (yyval)=N();
1.163 ! moko 2625: OA(*(yyval), OP::OP_STRING_POOL, (yyvsp[0])); /* stack: empty write context */
1.131 misha 2626: #endif
1.47 paf 2627: /* some code that writes to that context */
2628: /* context=pop; stack: context.get_string() */
1.158 misha 2629: }
1.163 ! moko 2630: #line 2631 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2631: break;
2632:
1.115 misha 2633: case 168:
1.163 ! moko 2634: #line 838 "compile.y" /* yacc.c:1646 */
1.112 paf 2635: {
1.131 misha 2636: // optimized OP_STRING+OP_WRITE_VALUE => OP_STRING__WRITE
1.163 ! moko 2637: change_string_literal_to_write_string_literal(*((yyval)=(yyvsp[0])));
1.158 misha 2638: }
1.163 ! moko 2639: #line 2640 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2640: break;
2641:
1.115 misha 2642: case 169:
1.163 ! moko 2643: #line 843 "compile.y" /* yacc.c:1646 */
1.158 misha 2644: { (yyval)=VL(/*we know that we will not change it*/const_cast<VString*>(&vempty), 0, 0, 0); }
1.163 ! moko 2645: #line 2646 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2646: break;
2647:
1.115 misha 2648: case 170:
1.163 ! moko 2649: #line 844 "compile.y" /* yacc.c:1646 */
1.158 misha 2650: { (yyval) = VL(/*we know that we will not change it*/const_cast<VBool*>(&vtrue), 0, 0, 0); }
1.163 ! moko 2651: #line 2652 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2652: break;
2653:
1.115 misha 2654: case 171:
1.163 ! moko 2655: #line 845 "compile.y" /* yacc.c:1646 */
1.158 misha 2656: { (yyval) = VL(/*we know that we will not change it*/const_cast<VBool*>(&vfalse), 0, 0, 0); }
1.163 ! moko 2657: #line 2658 "compile.tab.C" /* yacc.c:1646 */
1.112 paf 2658: break;
2659:
1.115 misha 2660: case 172:
1.163 ! moko 2661: #line 847 "compile.y" /* yacc.c:1646 */
1.158 misha 2662: { (yyval)=N(); }
1.163 ! moko 2663: #line 2664 "compile.tab.C" /* yacc.c:1646 */
1.155 misha 2664: break;
1.154 moko 2665:
1.112 paf 2666:
1.163 ! moko 2667: #line 2668 "compile.tab.C" /* yacc.c:1646 */
1.156 moko 2668: default: break;
1.155 misha 2669: }
1.158 misha 2670: /* User semantic actions sometimes alter yychar, and that requires
2671: that yytoken be updated with the new translation. We take the
2672: approach of translating immediately before every use of yytoken.
2673: One alternative is translating here after every semantic action,
2674: but that translation would be missed if the semantic action invokes
2675: YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2676: if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2677: incorrect destructor might then be invoked immediately. In the
2678: case of YYERROR or YYBACKUP, subsequent parser actions might lead
2679: to an incorrect destructor call or verbose syntax error message
2680: before the lookahead is translated. */
1.156 moko 2681: YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1.112 paf 2682:
1.156 moko 2683: YYPOPSTACK (yylen);
2684: yylen = 0;
1.112 paf 2685: YY_STACK_PRINT (yyss, yyssp);
1.1 parser 2686:
2687: *++yyvsp = yyval;
2688:
1.163 ! moko 2689: /* Now 'shift' the result of the reduction. Determine what state
1.112 paf 2690: that goes to, based on the state we popped back to and the rule
2691: number reduced by. */
1.1 parser 2692:
2693: yyn = yyr1[yyn];
2694:
1.112 paf 2695: yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2696: if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1.1 parser 2697: yystate = yytable[yystate];
2698: else
1.112 paf 2699: yystate = yydefgoto[yyn - YYNTOKENS];
1.1 parser 2700:
2701: goto yynewstate;
2702:
2703:
1.163 ! moko 2704: /*--------------------------------------.
! 2705: | yyerrlab -- here on detecting error. |
! 2706: `--------------------------------------*/
1.112 paf 2707: yyerrlab:
1.158 misha 2708: /* Make sure we have latest lookahead translation. See comments at
2709: user semantic actions for why this is necessary. */
2710: yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2711:
1.112 paf 2712: /* If not already recovering from an error, report this error. */
2713: if (!yyerrstatus)
1.1 parser 2714: {
2715: ++yynerrs;
1.156 moko 2716: #if ! YYERROR_VERBOSE
1.163 ! moko 2717: yyerror (pc, YY_("syntax error"));
1.156 moko 2718: #else
1.158 misha 2719: # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2720: yyssp, yytoken)
1.156 moko 2721: {
1.158 misha 2722: char const *yymsgp = YY_("syntax error");
2723: int yysyntax_error_status;
2724: yysyntax_error_status = YYSYNTAX_ERROR;
2725: if (yysyntax_error_status == 0)
2726: yymsgp = yymsg;
2727: else if (yysyntax_error_status == 1)
2728: {
2729: if (yymsg != yymsgbuf)
2730: YYSTACK_FREE (yymsg);
2731: yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2732: if (!yymsg)
2733: {
2734: yymsg = yymsgbuf;
2735: yymsg_alloc = sizeof yymsgbuf;
2736: yysyntax_error_status = 2;
2737: }
2738: else
2739: {
2740: yysyntax_error_status = YYSYNTAX_ERROR;
2741: yymsgp = yymsg;
2742: }
2743: }
1.163 ! moko 2744: yyerror (pc, yymsgp);
1.158 misha 2745: if (yysyntax_error_status == 2)
2746: goto yyexhaustedlab;
1.156 moko 2747: }
1.158 misha 2748: # undef YYSYNTAX_ERROR
1.156 moko 2749: #endif
1.1 parser 2750: }
2751:
1.112 paf 2752:
1.1 parser 2753:
2754: if (yyerrstatus == 3)
2755: {
1.112 paf 2756: /* If just tried and failed to reuse lookahead token after an
1.163 ! moko 2757: error, discard it. */
1.109 paf 2758:
1.113 paf 2759: if (yychar <= YYEOF)
1.163 ! moko 2760: {
! 2761: /* Return failure if at end of input. */
! 2762: if (yychar == YYEOF)
! 2763: YYABORT;
! 2764: }
1.113 paf 2765: else
1.163 ! moko 2766: {
! 2767: yydestruct ("Error: discarding",
! 2768: yytoken, &yylval, pc);
! 2769: yychar = YYEMPTY;
! 2770: }
1.106 paf 2771: }
1.1 parser 2772:
1.112 paf 2773: /* Else will try to reuse lookahead token after shifting the error
2774: token. */
2775: goto yyerrlab1;
1.109 paf 2776:
1.1 parser 2777:
1.113 paf 2778: /*---------------------------------------------------.
2779: | yyerrorlab -- error raised explicitly by YYERROR. |
2780: `---------------------------------------------------*/
2781: yyerrorlab:
2782:
1.156 moko 2783: /* Pacify compilers like GCC when the user code never invokes
2784: YYERROR and the label yyerrorlab therefore never appears in user
2785: code. */
2786: if (/*CONSTCOND*/ 0)
1.113 paf 2787: goto yyerrorlab;
2788:
1.163 ! moko 2789: /* Do not reclaim the symbols of the rule whose action triggered
1.156 moko 2790: this YYERROR. */
2791: YYPOPSTACK (yylen);
2792: yylen = 0;
2793: YY_STACK_PRINT (yyss, yyssp);
1.113 paf 2794: yystate = *yyssp;
2795: goto yyerrlab1;
2796:
2797:
2798: /*-------------------------------------------------------------.
2799: | yyerrlab1 -- common code for both syntax error and YYERROR. |
2800: `-------------------------------------------------------------*/
1.112 paf 2801: yyerrlab1:
1.163 ! moko 2802: yyerrstatus = 3; /* Each real token shifted decrements this. */
1.1 parser 2803:
1.112 paf 2804: for (;;)
1.109 paf 2805: {
1.112 paf 2806: yyn = yypact[yystate];
1.158 misha 2807: if (!yypact_value_is_default (yyn))
1.163 ! moko 2808: {
! 2809: yyn += YYTERROR;
! 2810: if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
! 2811: {
! 2812: yyn = yytable[yyn];
! 2813: if (0 < yyn)
! 2814: break;
! 2815: }
! 2816: }
1.1 parser 2817:
1.112 paf 2818: /* Pop the current state because it cannot handle the error token. */
2819: if (yyssp == yyss)
1.163 ! moko 2820: YYABORT;
1.1 parser 2821:
1.156 moko 2822:
2823: yydestruct ("Error: popping",
1.163 ! moko 2824: yystos[yystate], yyvsp, pc);
1.156 moko 2825: YYPOPSTACK (1);
1.113 paf 2826: yystate = *yyssp;
1.112 paf 2827: YY_STACK_PRINT (yyss, yyssp);
1.1 parser 2828: }
2829:
1.163 ! moko 2830: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1.156 moko 2831: *++yyvsp = yylval;
1.163 ! moko 2832: YY_IGNORE_MAYBE_UNINITIALIZED_END
1.155 misha 2833:
1.1 parser 2834:
1.156 moko 2835: /* Shift the error token. */
2836: YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1.112 paf 2837:
1.1 parser 2838: yystate = yyn;
2839: goto yynewstate;
2840:
2841:
1.112 paf 2842: /*-------------------------------------.
2843: | yyacceptlab -- YYACCEPT comes here. |
2844: `-------------------------------------*/
2845: yyacceptlab:
2846: yyresult = 0;
2847: goto yyreturn;
2848:
2849: /*-----------------------------------.
2850: | yyabortlab -- YYABORT comes here. |
2851: `-----------------------------------*/
2852: yyabortlab:
2853: yyresult = 1;
2854: goto yyreturn;
2855:
1.163 ! moko 2856: #if !defined yyoverflow || YYERROR_VERBOSE
1.156 moko 2857: /*-------------------------------------------------.
2858: | yyexhaustedlab -- memory exhaustion comes here. |
2859: `-------------------------------------------------*/
2860: yyexhaustedlab:
1.163 ! moko 2861: yyerror (pc, YY_("memory exhausted"));
1.112 paf 2862: yyresult = 2;
2863: /* Fall through. */
2864: #endif
2865:
2866: yyreturn:
1.156 moko 2867: if (yychar != YYEMPTY)
1.158 misha 2868: {
2869: /* Make sure we have latest lookahead translation. See comments at
2870: user semantic actions for why this is necessary. */
2871: yytoken = YYTRANSLATE (yychar);
2872: yydestruct ("Cleanup: discarding lookahead",
1.163 ! moko 2873: yytoken, &yylval, pc);
1.158 misha 2874: }
1.163 ! moko 2875: /* Do not reclaim the symbols of the rule whose action triggered
1.156 moko 2876: this YYABORT or YYACCEPT. */
2877: YYPOPSTACK (yylen);
2878: YY_STACK_PRINT (yyss, yyssp);
2879: while (yyssp != yyss)
2880: {
2881: yydestruct ("Cleanup: popping",
1.163 ! moko 2882: yystos[*yyssp], yyvsp, pc);
1.156 moko 2883: YYPOPSTACK (1);
2884: }
1.112 paf 2885: #ifndef yyoverflow
2886: if (yyss != yyssa)
2887: YYSTACK_FREE (yyss);
1.1 parser 2888: #endif
1.156 moko 2889: #if YYERROR_VERBOSE
2890: if (yymsg != yymsgbuf)
2891: YYSTACK_FREE (yymsg);
2892: #endif
1.163 ! moko 2893: return yyresult;
1.1 parser 2894: }
1.163 ! moko 2895: #line 849 "compile.y" /* yacc.c:1906 */
1.1 parser 2896:
2897: #endif
2898:
2899: /*
2900: 000$111(2222)00
2901: 000$111{3333}00
2902: $,^: push,=0
2903: 1:( { break=pop
2904: 2:( ) pop
2905: 3:{ } pop
2906:
2907: 000^111(2222)4444{33333}4000
2908: $,^: push,=0
2909: 1:( { break=pop
2910: 2:( )=4
2911: 3:{ }=4
2912: 4:[^({]=pop
2913: */
2914:
1.84 paf 2915: inline void ungetc(Parse_control& pc, uint last_line_end_col) {
2916: pc.source--;
2917: if(pc.pos.col==0) {
2918: --pc.pos.line; pc.pos.col=last_line_end_col;
2919: } else
2920: --pc.pos.col;
2921:
2922: }
2923: static int yylex(YYSTYPE *lvalp, void *apc) {
2924: register Parse_control& pc=*static_cast<Parse_control*>(apc);
2925:
2926: #define lexical_brackets_nestage pc.brackets_nestages[pc.ls_sp]
1.1 parser 2927: #define RC {result=c; goto break2; }
2928:
1.84 paf 2929: register int c;
2930: int result;
1.1 parser 2931:
1.84 paf 2932: if(pc.pending_state) {
2933: result=pc.pending_state;
2934: pc.pending_state=0;
1.1 parser 2935: return result;
2936: }
2937:
1.84 paf 2938: const char *begin=pc.source;
2939: Pos begin_pos=pc.pos;
1.1 parser 2940: const char *end;
2941: int skip_analized=0;
2942: while(true) {
1.84 paf 2943: c=*(end=(pc.source++));
2944: // fprintf(stderr, "\nchar: %c %02X; nestage: %d, sp=%d", c, c, lexical_brackets_nestage, pc.sp);
1.1 parser 2945:
1.96 paf 2946: if(c=='\n')
1.84 paf 2947: pc.pos_next_line();
1.96 paf 2948: else
1.84 paf 2949: pc.pos_next_c(c);
1.96 paf 2950: // fprintf(stderr, "\nchar: %c file(%d:%d)", c, pc.pos.line, pc.pos.col);
1.1 parser 2951:
1.96 paf 2952: if(pc.pos.col==0+1 && c=='@') {
1.84 paf 2953: if(pc.ls==LS_DEF_SPECIAL_BODY) {
1.31 paf 2954: // @SPECIAL
2955: // ...
2956: // @<here =
1.84 paf 2957: pop_LS(pc); // exiting from LS_DEF_SPECIAL_BODY state
1.31 paf 2958: } // continuing checks
1.84 paf 2959: if(pc.ls==LS_USER) {
2960: push_LS(pc, LS_DEF_NAME);
1.20 parser 2961: RC;
1.31 paf 2962: } else // @ in first column inside some code [when could that be?]
1.20 parser 2963: result=BAD_METHOD_DECL_START;
2964: goto break2;
1.97 paf 2965: }
2966: if(c=='^') {
1.84 paf 2967: if(pc.ls==LS_METHOD_AFTER) {
1.75 paf 2968: // handle after-method situation
1.84 paf 2969: pop_LS(pc);
1.75 paf 2970: result=EON;
2971: skip_analized=-1; // return to punctuation afterwards to assure it's literality
2972: goto break2;
2973: }
1.84 paf 2974: switch(pc.ls) {
1.15 parser 2975: case LS_EXPRESSION_VAR_NAME_WITH_COLON:
2976: case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON:
2977: case LS_VAR_NAME_SIMPLE_WITH_COLON:
2978: case LS_VAR_NAME_SIMPLE_WITHOUT_COLON:
2979: case LS_VAR_NAME_CURLY:
2980: case LS_METHOD_NAME:
1.66 paf 2981: case LS_USER_COMMENT:
1.15 parser 2982: case LS_DEF_COMMENT:
2983: // no literals in names, please
2984: break;
2985: default:
1.84 paf 2986: switch(*pc.source) {
1.10 parser 2987: // ^escaping some punctuators
1.121 misha 2988: case '^': case '$': case ';': case '@':
1.1 parser 2989: case '(': case ')':
2990: case '[': case ']':
2991: case '{': case '}':
1.23 parser 2992: case '"': case ':':
1.1 parser 2993: if(end!=begin) {
1.84 paf 2994: if(!pc.string_start)
2995: pc.string_start=begin_pos;
1.1 parser 2996: // append piece till ^
1.84 paf 2997: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 2998: }
2999: // reset piece 'begin' position & line
1.84 paf 3000: begin=pc.source; // ->punctuation
3001: begin_pos=pc.pos;
1.75 paf 3002: // skip over _ after ^
1.84 paf 3003: pc.source++; pc.pos.col++;
1.75 paf 3004: // skip analysis = forced literal
3005: continue;
1.1 parser 3006:
3007: // converting ^#HH into char(hex(HH))
3008: case '#':
3009: if(end!=begin) {
1.84 paf 3010: if(!pc.string_start)
3011: pc.string_start=begin_pos;
1.1 parser 3012: // append piece till ^
1.84 paf 3013: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 3014: }
3015: // #HH ?
1.121 misha 3016: if(pc.source[1] && isxdigit(pc.source[1]) && pc.source[2] && isxdigit(pc.source[2])) {
1.110 paf 3017: char c=(char)(
1.84 paf 3018: hex_value[(unsigned char)pc.source[1]]*0x10+
1.110 paf 3019: hex_value[(unsigned char)pc.source[2]]);
1.84 paf 3020: if(c==0) {
1.1 parser 3021: result=BAD_HEX_LITERAL;
3022: goto break2; // wrong hex value[no ^#00 chars allowed]: bail out
3023: }
3024: // append char(hex(HH))
1.84 paf 3025: pc.string.append(c);
1.1 parser 3026: // skip over ^#HH
1.84 paf 3027: pc.source+=3;
3028: pc.pos.col+=3;
1.1 parser 3029: // reset piece 'begin' position & line
1.84 paf 3030: begin=pc.source; // ->after ^#HH
3031: begin_pos=pc.pos;
1.75 paf 3032: // skip analysis = forced literal
1.1 parser 3033: continue;
3034: }
1.121 misha 3035: // just escaped char
3036: // reset piece 'begin' position & line
3037: begin=pc.source;
3038: begin_pos=pc.pos;
3039: // skip over _ after ^
3040: pc.source++; pc.pos.col++;
3041: // skip analysis = forced literal
3042: continue;
1.1 parser 3043: }
1.15 parser 3044: break;
1.75 paf 3045: }
1.15 parser 3046: }
1.1 parser 3047: // #comment start skipping
1.84 paf 3048: if(c=='#' && pc.pos.col==1) {
1.1 parser 3049: if(end!=begin) {
1.84 paf 3050: if(!pc.string_start)
3051: pc.string_start=begin_pos;
1.1 parser 3052: // append piece till #
1.84 paf 3053: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 3054: }
3055: // fall into COMMENT lexical state [wait for \n]
1.84 paf 3056: push_LS(pc, LS_USER_COMMENT);
1.31 paf 3057: continue;
1.1 parser 3058: }
1.84 paf 3059: switch(pc.ls) {
1.1 parser 3060:
3061: // USER'S = NOT OURS
3062: case LS_USER:
1.84 paf 3063: case LS_NAME_SQUARE_PART: // name.[here].xxx
3064: if(pc.trim_bof)
1.1 parser 3065: switch(c) {
3066: case '\n': case ' ': case '\t':
1.84 paf 3067: begin=pc.source;
3068: begin_pos=pc.pos;
1.1 parser 3069: continue; // skip it
3070: default:
1.84 paf 3071: pc.trim_bof=false;
1.1 parser 3072: }
3073: switch(c) {
3074: case '$':
1.84 paf 3075: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3076: RC;
3077: case '^':
1.84 paf 3078: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3079: RC;
1.11 parser 3080: case ']':
1.84 paf 3081: if(pc.ls==LS_NAME_SQUARE_PART)
1.11 parser 3082: if(--lexical_brackets_nestage==0) {// $name.[co<]?>de<]?>
1.84 paf 3083: pop_LS(pc); // $name.[co<]>de<]!>
1.11 parser 3084: RC;
3085: }
1.3 parser 3086: break;
1.11 parser 3087: case '[': // $name.[co<[>de]
1.84 paf 3088: if(pc.ls==LS_NAME_SQUARE_PART)
1.11 parser 3089: lexical_brackets_nestage++;
1.4 parser 3090: break;
1.1 parser 3091: }
1.97 paf 3092: if(pc.explicit_result && c)
3093: switch(c) {
3094: case '\n': case ' ': case '\t':
3095: begin=pc.source;
3096: begin_pos=pc.pos;
3097: continue; // skip it
3098: default:
3099: result=BAD_NONWHITESPACE_CHARACTER_IN_EXPLICIT_RESULT_MODE;
3100: goto break2;
3101: }
1.1 parser 3102: break;
3103:
3104: // #COMMENT
1.66 paf 3105: case LS_USER_COMMENT:
1.1 parser 3106: if(c=='\n') {
3107: // skip comment
1.84 paf 3108: begin=pc.source;
3109: begin_pos=pc.pos;
1.1 parser 3110:
1.84 paf 3111: pop_LS(pc);
1.1 parser 3112: continue;
3113: }
3114: break;
3115:
3116: // STRING IN EXPRESSION
3117: case LS_EXPRESSION_STRING_QUOTED:
3118: case LS_EXPRESSION_STRING_APOSTROFED:
3119: switch(c) {
3120: case '"':
3121: case '\'':
3122: if(
1.162 moko 3123: (pc.ls == LS_EXPRESSION_STRING_QUOTED && c=='"') ||
3124: (pc.ls == LS_EXPRESSION_STRING_APOSTROFED && c=='\'') ) {
1.84 paf 3125: pop_LS(pc); //"abc". | 'abc'.
1.1 parser 3126: RC;
3127: }
3128: break;
3129: case '$':
1.84 paf 3130: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3131: RC;
3132: case '^':
1.84 paf 3133: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3134: RC;
3135: }
3136: break;
3137:
3138: // METHOD DEFINITION
3139: case LS_DEF_NAME:
3140: switch(c) {
3141: case '[':
1.84 paf 3142: pc.ls=LS_DEF_PARAMS;
1.1 parser 3143: RC;
3144: case '\n':
1.84 paf 3145: pc.ls=LS_DEF_SPECIAL_BODY;
1.1 parser 3146: RC;
3147: }
3148: break;
3149:
3150: case LS_DEF_PARAMS:
3151: switch(c) {
1.64 paf 3152: case '$': // common error
1.65 paf 3153: result=BAD_METHOD_PARAMETER_NAME_CHARACTER;
3154: goto break2;
1.1 parser 3155: case ';':
3156: RC;
3157: case ']':
1.84 paf 3158: pc.ls=*pc.source=='['?LS_DEF_LOCALS:LS_DEF_COMMENT;
1.1 parser 3159: RC;
3160: case '\n': // wrong. bailing out
1.84 paf 3161: pop_LS(pc);
1.1 parser 3162: RC;
3163: }
3164: break;
3165:
3166: case LS_DEF_LOCALS:
3167: switch(c) {
3168: case '[':
3169: case ';':
3170: RC;
3171: case ']':
1.84 paf 3172: pc.ls=LS_DEF_COMMENT;
1.1 parser 3173: RC;
3174: case '\n': // wrong. bailing out
1.84 paf 3175: pop_LS(pc);
1.1 parser 3176: RC;
3177: }
3178: break;
3179:
3180: case LS_DEF_COMMENT:
3181: if(c=='\n') {
1.84 paf 3182: pop_LS(pc);
1.1 parser 3183: RC;
3184: }
3185: break;
3186:
3187: case LS_DEF_SPECIAL_BODY:
1.31 paf 3188: if(c=='\n')
1.1 parser 3189: RC;
3190: break;
3191:
3192: // (EXPRESSION)
3193: case LS_VAR_ROUND:
3194: case LS_METHOD_ROUND:
3195: switch(c) {
3196: case ')':
1.162 moko 3197: if(--lexical_brackets_nestage==0) {
1.84 paf 3198: if(pc.ls==LS_METHOD_ROUND) // method round param ended
3199: pc.ls=LS_METHOD_AFTER; // look for method end
3200: else // pc.ls==LS_VAR_ROUND // variable constructor ended
3201: pop_LS(pc); // return to normal life
1.162 moko 3202: }
1.1 parser 3203: RC;
1.66 paf 3204: case '#': // comment start skipping
3205: if(end!=begin) {
1.84 paf 3206: if(!pc.string_start)
3207: pc.string_start=begin_pos;
1.66 paf 3208: // append piece till #
1.84 paf 3209: pc.string.append_strdup_know_length(begin, end-begin);
1.66 paf 3210: }
3211: // fall into COMMENT lexical state [wait for \n]
1.84 paf 3212: push_LS(pc, LS_EXPRESSION_COMMENT);
1.66 paf 3213: lexical_brackets_nestage=1;
3214: continue;
1.1 parser 3215: case '$':
1.84 paf 3216: push_LS(pc, LS_EXPRESSION_VAR_NAME_WITH_COLON);
1.1 parser 3217: RC;
3218: case '^':
1.84 paf 3219: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3220: RC;
3221: case '(':
3222: lexical_brackets_nestage++;
3223: RC;
3224: case '-':
1.84 paf 3225: switch(*pc.source) {
1.1 parser 3226: case 'f': // -f
3227: skip_analized=1;
3228: result=FEXISTS;
3229: goto break2;
3230: case 'd': // -d
3231: skip_analized=1;
3232: result=DEXISTS;
3233: goto break2;
1.63 paf 3234: default: // minus
1.1 parser 3235: result=c;
3236: goto break2;
3237: }
3238: goto break2;
1.25 paf 3239: case '+': case '*': case '/': case '%': case '\\':
1.1 parser 3240: case '~':
3241: case ';':
3242: RC;
1.65 paf 3243: case '&': case '|':
1.84 paf 3244: if(*pc.source==c) { // && ||
1.65 paf 3245: result=c=='&'?LAND:LOR;
1.1 parser 3246: skip_analized=1;
3247: } else
3248: result=c;
3249: goto break2;
1.65 paf 3250: case '!':
1.84 paf 3251: switch(pc.source[0]) {
1.65 paf 3252: case '|': // !| !||
3253: skip_analized=1;
1.84 paf 3254: if(pc.source[1]=='|') {
1.65 paf 3255: skip_analized++;
3256: result=LXOR;
3257: } else
3258: result=NXOR;
3259: goto break2;
3260: case '=': // !=
3261: skip_analized=1;
3262: result=NNE;
3263: goto break2;
3264: }
3265: RC;
1.67 paf 3266:
3267: case '<': // <<, <=, <
1.84 paf 3268: switch(*pc.source) {
1.67 paf 3269: case '<': // <[<]
3270: skip_analized=1; result=NSL; break;
3271: case '=': // <[=]
3272: skip_analized=1; result=NLE; break;
3273: default: // <[]
3274: result=c; break;
3275: }
3276: goto break2;
3277: case '>': // >>, >=, >
1.84 paf 3278: switch(*pc.source) {
1.67 paf 3279: case '>': // >[>]
3280: skip_analized=1; result=NSR; break;
3281: case '=': // >[=]
3282: skip_analized=1; result=NGE; break;
3283: default: // >[]
3284: result=c; break;
3285: }
3286: goto break2;
3287: case '=': // ==
1.84 paf 3288: switch(*pc.source) {
1.67 paf 3289: case '=': // =[=]
3290: skip_analized=1; result=NEQ; break;
3291: default: // =[]
3292: result=c; break; // not used now
3293: }
1.1 parser 3294: goto break2;
1.67 paf 3295:
1.1 parser 3296: case '"':
1.84 paf 3297: push_LS(pc, LS_EXPRESSION_STRING_QUOTED);
1.1 parser 3298: RC;
3299: case '\'':
1.84 paf 3300: push_LS(pc, LS_EXPRESSION_STRING_APOSTROFED);
1.1 parser 3301: RC;
3302: case 'l': case 'g': case 'e': case 'n':
3303: if(end==begin) // right after whitespace
1.84 paf 3304: if(isspace(pc.source[1])) {
3305: switch(*pc.source) {
1.1 parser 3306: // case '?': // ok [and bad cases, yacc would bark at them]
3307: case 't': // lt gt [et nt]
3308: result=c=='l'?SLT:c=='g'?SGT:BAD_STRING_COMPARISON_OPERATOR;
3309: skip_analized=1;
3310: goto break2;
3311: case 'e': // le ge ne [ee]
3312: result=c=='l'?SLE:c=='g'?SGE:c=='n'?SNE:BAD_STRING_COMPARISON_OPERATOR;
3313: skip_analized=1;
3314: goto break2;
3315: case 'q': // eq [lq gq nq]
3316: result=c=='e'?SEQ:BAD_STRING_COMPARISON_OPERATOR;
3317: skip_analized=1;
3318: goto break2;
3319: }
3320: }
3321: break;
3322: case 'i':
3323: if(end==begin) // right after whitespace
1.84 paf 3324: if(isspace(pc.source[1])) {
3325: switch(pc.source[0]) {
1.1 parser 3326: case 'n': // in
3327: skip_analized=1;
3328: result=IN;
3329: goto break2;
3330: case 's': // is
3331: skip_analized=1;
3332: result=IS;
3333: goto break2;
3334: }
3335: }
3336: break;
3337: case 'd':
3338: if(end==begin) // right after whitespace
1.84 paf 3339: if(pc.source[0]=='e' && pc.source[1]=='f') { // def
1.118 misha 3340: switch(pc.source[2]){
3341: case ' ': case '\t': case '\n': case '"': case '\'': case '^': case '$': // non-quoted string without whitespace after 'def' is not allowed
3342: skip_analized=2;
3343: result=DEF;
3344: goto break2;
3345: }
3346: // error: incorrect char after 'def'
1.1 parser 3347: }
3348: break;
1.107 paf 3349: case 't':
3350: if(end==begin) // right after whitespace
1.118 misha 3351: if(pc.source[0]=='r' && pc.source[1]=='u' && pc.source[2]=='e') { // true
1.107 paf 3352: skip_analized=3;
3353: result=LITERAL_TRUE;
3354: goto break2;
3355: }
3356: break;
3357: case 'f':
3358: if(end==begin) // right after whitespace
1.118 misha 3359: if(pc.source[0]=='a' && pc.source[1]=='l' && pc.source[2]=='s' && pc.source[3]=='e') { // false
1.107 paf 3360: skip_analized=4;
3361: result=LITERAL_FALSE;
3362: goto break2;
3363: }
3364: break;
1.1 parser 3365: case ' ': case '\t': case '\n':
3366: if(end!=begin) { // there were a string after previous operator?
3367: result=0; // return that string
3368: goto break2;
3369: }
3370: // that's a leading|traling space or after-operator-space
3371: // ignoring it
3372: // reset piece 'begin' position & line
1.84 paf 3373: begin=pc.source; // after whitespace char
3374: begin_pos=pc.pos;
1.1 parser 3375: continue;
3376: }
3377: break;
1.66 paf 3378: case LS_EXPRESSION_COMMENT:
3379: if(c=='(')
3380: lexical_brackets_nestage++;
3381:
1.84 paf 3382: switch(*pc.source) {
1.66 paf 3383: case '\n': case ')':
1.84 paf 3384: if(*pc.source==')')
1.66 paf 3385: if(--lexical_brackets_nestage!=0)
3386: continue;
3387:
3388: // skip comment
1.84 paf 3389: begin=pc.source;
3390: begin_pos=pc.pos;
1.66 paf 3391:
1.84 paf 3392: pop_LS(pc);
1.66 paf 3393: continue;
3394: }
3395: break;
1.1 parser 3396:
3397: // VARIABLE GET/PUT/WITH
1.11 parser 3398: case LS_VAR_NAME_SIMPLE_WITH_COLON:
3399: case LS_VAR_NAME_SIMPLE_WITHOUT_COLON:
3400: case LS_EXPRESSION_VAR_NAME_WITH_COLON:
3401: case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON:
3402: if(
1.84 paf 3403: pc.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON ||
3404: pc.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) {
1.41 paf 3405: // name in expr ends also before
1.1 parser 3406: switch(c) {
1.41 paf 3407: // expression minus
1.1 parser 3408: case '-':
1.41 paf 3409: // expression integer division
3410: case '\\':
1.84 paf 3411: pop_LS(pc);
3412: pc.ungetc();
1.1 parser 3413: result=EON;
3414: goto break2;
3415: }
3416: }
1.11 parser 3417: if(
1.84 paf 3418: pc.ls==LS_VAR_NAME_SIMPLE_WITHOUT_COLON ||
3419: pc.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) {
1.1 parser 3420: // name already has ':', stop before next
3421: switch(c) {
3422: case ':':
1.84 paf 3423: pop_LS(pc);
3424: pc.ungetc();
1.1 parser 3425: result=EON;
3426: goto break2;
3427: }
3428: }
3429: switch(c) {
3430: case 0:
3431: case ' ': case '\t': case '\n':
3432: case ';':
3433: case ']': case '}': case ')':
3434: case '"': case '\'':
3435: case '<': case '>': // these stand for HTML brackets AND expression binary ops
1.146 misha 3436: case '+': case '*': case '/': case '\\': case '%':
1.1 parser 3437: case '&': case '|':
3438: case '=': case '!':
3439: // common delimiters
1.62 paf 3440: case ',': case '?': case '#':
1.113 paf 3441: // mysql column separators
3442: case '`':
1.1 parser 3443: // before call
3444: case '^':
1.84 paf 3445: pop_LS(pc);
3446: pc.ungetc();
1.1 parser 3447: result=EON;
3448: goto break2;
3449: case '[':
1.5 parser 3450: // $name.<[>code]
1.84 paf 3451: if(pc.pos.col>1/*not first column*/ && (
1.6 parser 3452: end[-1]=='$'/*was start of get*/ ||
3453: end[-1]==':'/*was class name delim */ ||
3454: end[-1]=='.'/*was name delim */
1.5 parser 3455: )) {
1.84 paf 3456: push_LS(pc, LS_NAME_SQUARE_PART);
1.5 parser 3457: lexical_brackets_nestage=1;
3458: RC;
3459: }
1.84 paf 3460: pc.ls=LS_VAR_SQUARE;
1.1 parser 3461: lexical_brackets_nestage=1;
3462: RC;
3463: case '{':
3464: if(begin==end) { // ${name}, no need of EON, switching LS
1.84 paf 3465: pc.ls=LS_VAR_NAME_CURLY;
1.1 parser 3466: } else {
1.84 paf 3467: pc.ls=LS_VAR_CURLY;
1.1 parser 3468: lexical_brackets_nestage=1;
3469: }
3470:
3471: RC;
3472: case '(':
1.84 paf 3473: pc.ls=LS_VAR_ROUND;
1.1 parser 3474: lexical_brackets_nestage=1;
3475: RC;
3476: case '.': // name part delim
3477: case '$': // name part subvar
1.3 parser 3478: case ':': // class<:>name
1.11 parser 3479: // go to _WITHOUT_COLON state variant...
1.84 paf 3480: if(pc.ls==LS_VAR_NAME_SIMPLE_WITH_COLON)
3481: pc.ls=LS_VAR_NAME_SIMPLE_WITHOUT_COLON;
3482: else if(pc.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON)
3483: pc.ls=LS_EXPRESSION_VAR_NAME_WITHOUT_COLON;
1.11 parser 3484: // ...stop before next ':'
1.1 parser 3485: RC;
3486: }
3487: break;
3488:
3489: case LS_VAR_NAME_CURLY:
3490: switch(c) {
1.5 parser 3491: case '[':
1.11 parser 3492: // ${name.<[>code]}
1.84 paf 3493: push_LS(pc, LS_NAME_SQUARE_PART);
1.3 parser 3494: lexical_brackets_nestage=1;
3495: RC;
1.1 parser 3496: case '}': // ${name} finished, restoring LS
1.84 paf 3497: pop_LS(pc);
1.1 parser 3498: RC;
3499: case '.': // name part delim
3500: case '$': // name part subvar
3501: case ':': // ':name' or 'class:name'
3502: RC;
3503: }
3504: break;
3505:
3506: case LS_VAR_SQUARE:
3507: switch(c) {
3508: case '$':
1.84 paf 3509: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3510: RC;
3511: case '^':
1.84 paf 3512: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3513: RC;
3514: case ']':
3515: if(--lexical_brackets_nestage==0) {
1.84 paf 3516: pop_LS(pc);
1.1 parser 3517: RC;
3518: }
3519: break;
3520: case ';': // operator_or_fmt;value delim
3521: RC;
3522: case '[':
3523: lexical_brackets_nestage++;
3524: break;
3525: }
3526: break;
3527:
3528: case LS_VAR_CURLY:
3529: switch(c) {
3530: case '$':
1.84 paf 3531: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3532: RC;
3533: case '^':
1.84 paf 3534: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3535: RC;
3536: case '}':
3537: if(--lexical_brackets_nestage==0) {
1.84 paf 3538: pop_LS(pc);
1.1 parser 3539: RC;
3540: }
3541: break;
3542: case '{':
3543: lexical_brackets_nestage++;
3544: break;
3545: }
3546: break;
3547:
3548: // METHOD CALL
3549: case LS_METHOD_NAME:
3550: switch(c) {
3551: case '[':
1.11 parser 3552: // ^name.<[>code].xxx
1.84 paf 3553: if(pc.pos.col>1/*not first column*/ && (
1.6 parser 3554: end[-1]=='^'/*was start of call*/ || // never, ^[ is literal...
3555: end[-1]==':'/*was class name delim */ ||
3556: end[-1]=='.'/*was name delim */
1.5 parser 3557: )) {
1.84 paf 3558: push_LS(pc, LS_NAME_SQUARE_PART);
1.5 parser 3559: lexical_brackets_nestage=1;
3560: RC;
3561: }
1.84 paf 3562: pc.ls=LS_METHOD_SQUARE;
1.1 parser 3563: lexical_brackets_nestage=1;
3564: RC;
3565: case '{':
1.84 paf 3566: pc.ls=LS_METHOD_CURLY;
1.1 parser 3567: lexical_brackets_nestage=1;
3568: RC;
3569: case '(':
1.84 paf 3570: pc.ls=LS_METHOD_ROUND;
1.1 parser 3571: lexical_brackets_nestage=1;
3572: RC;
3573: case '.': // name part delim
3574: case '$': // name part subvar
3575: case ':': // ':name' or 'class:name'
1.19 parser 3576: case '^': // ^abc^xxx wrong. bailing out
3577: case ']': case '}': case ')': // ^abc]}) wrong. bailing out
1.90 paf 3578: case ' ': // ^if ( wrong. bailing out
1.1 parser 3579: RC;
3580: }
3581: break;
3582:
3583: case LS_METHOD_SQUARE:
3584: switch(c) {
3585: case '$':
1.84 paf 3586: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3587: RC;
3588: case '^':
1.84 paf 3589: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3590: RC;
3591: case ';': // param delim
3592: RC;
3593: case ']':
3594: if(--lexical_brackets_nestage==0) {
1.84 paf 3595: pc.ls=LS_METHOD_AFTER;
1.1 parser 3596: RC;
3597: }
3598: break;
3599: case '[':
3600: lexical_brackets_nestage++;
3601: break;
3602: }
3603: break;
3604:
3605: case LS_METHOD_CURLY:
3606: switch(c) {
3607: case '$':
1.84 paf 3608: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3609: RC;
3610: case '^':
1.84 paf 3611: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3612: RC;
3613: case ';': // param delim
3614: RC;
3615: case '}':
3616: if(--lexical_brackets_nestage==0) {
1.84 paf 3617: pc.ls=LS_METHOD_AFTER;
1.1 parser 3618: RC;
3619: }
3620: break;
3621: case '{':
3622: lexical_brackets_nestage++;
3623: break;
3624: }
1.97 paf 3625: if(pc.explicit_result && c)
3626: switch(c) {
3627: case '\n': case ' ': case '\t':
3628: begin=pc.source;
3629: begin_pos=pc.pos;
3630: continue; // skip it
3631: default:
3632: result=BAD_NONWHITESPACE_CHARACTER_IN_EXPLICIT_RESULT_MODE;
3633: goto break2;
3634: }
1.1 parser 3635: break;
3636:
3637: case LS_METHOD_AFTER:
3638: if(c=='[') {/* ][ }[ )[ */
1.84 paf 3639: pc.ls=LS_METHOD_SQUARE;
1.1 parser 3640: lexical_brackets_nestage=1;
3641: RC;
3642: }
3643: if(c=='{') {/* ]{ }{ ){ */
1.84 paf 3644: pc.ls=LS_METHOD_CURLY;
1.1 parser 3645: lexical_brackets_nestage=1;
3646: RC;
3647: }
3648: if(c=='(') {/* ]( }( )( */
1.84 paf 3649: pc.ls=LS_METHOD_ROUND;
1.1 parser 3650: lexical_brackets_nestage=1;
3651: RC;
3652: }
1.84 paf 3653: pop_LS(pc);
3654: pc.ungetc();
1.1 parser 3655: result=EON;
3656: goto break2;
3657: }
3658: if(c==0) {
3659: result=-1;
3660: break;
3661: }
3662: }
3663:
3664: break2:
3665: if(end!=begin) { // there is last piece?
1.150 misha 3666: if(c=='@' || c==0) // we are before LS_DEF_NAME or EOF?
3667: while(end!=begin && end[-1]=='\n') // trim all empty lines before LS_DEF_NAME and EOF
1.1 parser 3668: end--;
1.84 paf 3669: if(end!=begin && pc.ls!=LS_USER_COMMENT) { // last piece still alive and not comment?
3670: if(!pc.string_start)
3671: pc.string_start=begin_pos;
1.1 parser 3672: // append it
1.84 paf 3673: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 3674: }
3675: }
1.84 paf 3676: if(!pc.string.is_empty()) { // something accumulated?
3677: // create STRING value: array of OP_VALUE+origin+vstring
3678: *lvalp=VL(
3679: new VString(*new String(pc.string, String::L_CLEAN)),
3680: pc.file_no, pc.string_start.line, pc.string_start.col);
1.1 parser 3681: // new pieces storage
1.84 paf 3682: pc.string.clear();
3683: pc.string_start.clear();
1.1 parser 3684: // make current result be pending for next call, return STRING for now
1.84 paf 3685: pc.pending_state=result; result=STRING;
1.1 parser 3686: }
3687: if(skip_analized) {
1.84 paf 3688: pc.source+=skip_analized; pc.pos.col+=skip_analized;
1.1 parser 3689: }
3690: return result;
3691: }
3692:
1.156 moko 3693: static int real_yyerror(Parse_control *pc, const char *s) { // Called by yyparse on error
1.10 parser 3694: strncpy(PC.error, s, MAX_STRING);
1.1 parser 3695: return 1;
3696: }
3697:
3698: static void yyprint(FILE *file, int type, YYSTYPE value) {
3699: if(type==STRING)
1.84 paf 3700: fprintf(file, " \"%s\"", LA2S(*value)->cstr());
1.1 parser 3701: }
E-mail: