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