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