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