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