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