Annotation of parser3/src/main/compile.tab.C, revision 1.197
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.197 ! moko 81: volatile const char * IDENT_COMPILE_Y = "$Id: compile.y,v 1.307 2026/10/05 17:50:18 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.197 ! moko 789: 0, 153, 153, 158, 160, 160, 161, 163, 163, 165,
! 790: 241, 241, 242, 242, 243, 244, 244, 246, 246, 294,
! 791: 294, 295, 296, 296, 297, 297, 299, 299, 303, 303,
! 792: 305, 305, 306, 306, 307, 307, 307, 311, 342, 343,
! 793: 343, 344, 346, 347, 348, 397, 398, 398, 402, 415,
! 794: 416, 417, 418, 440, 445, 448, 449, 450, 452, 456,
! 795: 452, 471, 472, 474, 481, 488, 489, 490, 492, 498,
! 796: 499, 499, 503, 514, 517, 514, 566, 582, 582, 584,
! 797: 585, 586, 588, 591, 588, 594, 595, 597, 598, 601,
! 798: 602, 605, 606, 608, 611, 624, 629, 630, 631, 636,
! 799: 636, 638, 638, 639, 640, 652, 661, 664, 665, 666,
! 800: 667, 668, 670, 674, 683, 686, 683, 696, 700, 705,
! 801: 705, 706, 712, 713, 715, 734, 744, 746, 747, 748,
! 802: 749, 750, 751, 752, 753, 755, 756, 757, 758, 759,
! 803: 760, 761, 762, 764, 765, 766, 767, 768, 769, 770,
! 804: 771, 772, 773, 774, 775, 776, 777, 778, 779, 780,
! 805: 781, 782, 783, 784, 785, 786, 787, 788, 789, 790,
! 806: 793, 798, 819, 824, 825, 826, 828
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.197 ! moko 1920: RECORD(MAIN, &PC.alias_method(main_method_name), method);
1.158 misha 1921: }
1.197 ! moko 1922: #line 1923 "compile.tab.C"
1.112 paf 1923: break;
1924:
1.196 moko 1925: case 9: /* control_method: '@' STRING '\n' maybe_control_strings */
1.197 ! moko 1926: #line 166 "compile.y"
1.196 moko 1927: {
1.181 moko 1928: const String& command=LA2S(*yyvsp[-2])->trim(String::TRIM_END);
1929: YYSTYPE strings_code=yyvsp[0];
1930: if(strings_code->count()<1*OPERATIONS_PER_OPVALUE)
1931: YYERROR3("@", command.cstr(), " is empty");
1.1 parser 1932: if(command==CLASS_NAME) {
1.84 paf 1933: if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) {
1.157 moko 1934: CLASS_ADD;
1.1 parser 1935: // new class' name
1.152 misha 1936: const String& name=LA2S(*strings_code)->trim(String::TRIM_END);
1.1 parser 1937: // creating the class
1.177 moko 1938: VStateless_class* cclass=new VClass(name.cstr(), PC.request.get_used_filespec(PC.file_no));
1.119 misha 1939: PC.cclass_new=cclass;
1.158 misha 1940: PC.append=false;
1.197 ! moko 1941: RECORD(CLASS, &name);
1.1 parser 1942: } else {
1.187 moko 1943: YYERROR1("@" CLASS_NAME " must contain only one line with class name (contains more than one)");
1.1 parser 1944: }
1945: } else if(command==USE_CONTROL_METHOD_NAME) {
1.157 moko 1946: CLASS_ADD;
1.165 moko 1947: for(size_t i=0; i<strings_code->count(); i+=OPERATIONS_PER_OPVALUE){
1.197 ! moko 1948: const String& file_name=LA2S(*strings_code, i)->trim(String::TRIM_END);
! 1949: PC.request.use_file(file_name, PC.request.get_used_filespec(PC.file_no), strings_code->get(i+1).origin);
! 1950: RECORD_USE(&file_name, strings_code->get(i+1).origin);
1.165 moko 1951: }
1.1 parser 1952: } else if(command==BASE_NAME) {
1.181 moko 1953: if(PC.append)
1954: YYERROR3("can't set base while appending methods to class '", PC.cclass->type(), "'");
1.157 moko 1955: CLASS_ADD;
1.181 moko 1956: if(PC.cclass->base_class()) // already changed from default?
1957: YYERROR3("class already have a base '", PC.cclass->base_class()->type(), "'");
1.84 paf 1958: if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) {
1.152 misha 1959: const String& base_name=LA2S(*strings_code)->trim(String::TRIM_END);
1.173 moko 1960: if(VStateless_class *base_class=PC.request.get_class(base_name)) {
1.84 paf 1961: // @CLASS == @BASE sanity check
1.181 moko 1962: if(PC.cclass==base_class)
1963: YYERROR1("@" CLASS_NAME " equals @" BASE_NAME);
1.173 moko 1964: PC.cclass->get_class()->set_base(base_class);
1.197 ! moko 1965: RECORD(BASE, &base_name);
1.84 paf 1966: } else {
1.181 moko 1967: YYERROR3("'", base_name.cstr(), "': undefined class in @" BASE_NAME);
1.1 parser 1968: }
1969: } else {
1.181 moko 1970: YYERROR1("@" BASE_NAME " must contain sole name");
1.1 parser 1971: }
1.116 misha 1972: } else if(command==OPTIONS_CONTROL_METHOD_NAME) {
1.118 misha 1973: for(size_t i=0; i<strings_code->count(); i+=OPERATIONS_PER_OPVALUE) {
1.152 misha 1974: const String& option=LA2S(*strings_code, i)->trim(String::TRIM_END);
1.170 moko 1975: if(option==Symbols::LOCALS_SYMBOL){
1.119 misha 1976: PC.set_all_vars_local();
1.170 moko 1977: } else if(option==Symbols::PARTIAL_SYMBOL){
1.123 misha 1978: if(PC.cclass_new){
1979: if(VStateless_class* existed=PC.get_existed_class(PC.cclass_new)){
1.181 moko 1980: if(!PC.reuse_existed_class(existed))
1981: YYERROR3("can't append methods to '", PC.cclass_new->type(), "' - the class wasn't marked as partial");
1.119 misha 1982: } else {
1.149 misha 1983: // marks the new class as partial. we will be able to add methods here later.
1.123 misha 1984: PC.cclass_new->set_partial();
1.119 misha 1985: }
1.123 misha 1986: } else {
1.181 moko 1987: YYERROR1("'partial' option should be used straight after @" CLASS_NAME);
1.119 misha 1988: }
1.170 moko 1989: } else if(option==Symbols::STATIC_SYMBOL){
1.149 misha 1990: PC.set_methods_call_type(Method::CT_STATIC);
1.170 moko 1991: } else if(option==Symbols::DYNAMIC_SYMBOL){
1.149 misha 1992: PC.set_methods_call_type(Method::CT_DYNAMIC);
1.118 misha 1993: } else {
1.181 moko 1994: YYERROR3("'", option.cstr(), "' invalid option. valid options are 'partial', 'locals', 'static' and 'dynamic'");
1.116 misha 1995: }
1.197 ! moko 1996: RECORD(OPTION, &option);
1.116 misha 1997: }
1.1 parser 1998: } else {
1.181 moko 1999: 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 2000: }
1.158 misha 2001: }
1.197 ! moko 2002: #line 2003 "compile.tab.C"
1.112 paf 2003: break;
2004:
1.196 moko 2005: case 13: /* control_strings: control_strings control_string */
1.197 ! moko 2006: #line 242 "compile.y"
1.196 moko 2007: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2008: #line 2009 "compile.tab.C"
1.112 paf 2009: break;
2010:
1.196 moko 2011: case 17: /* @1: %empty */
1.197 ! moko 2012: #line 246 "compile.y"
1.196 moko 2013: {
1.157 moko 2014: CLASS_ADD;
1.96 paf 2015: PC.explicit_result=false;
1.1 parser 2016:
1.181 moko 2017: YYSTYPE params_names_code=yyvsp[-3];
1.84 paf 2018: ArrayString* params_names=0;
2019: if(int size=params_names_code->count()) {
2020: params_names=new ArrayString;
2021: for(int i=0; i<size; i+=OPERATIONS_PER_OPVALUE)
2022: *params_names+=LA2S(*params_names_code, i);
1.1 parser 2023: }
2024:
1.181 moko 2025: YYSTYPE locals_names_code=yyvsp[-2];
1.84 paf 2026: ArrayString* locals_names=0;
1.174 moko 2027: bool all_vars_local=PC.cclass->is_vars_local();
2028:
1.84 paf 2029: if(int size=locals_names_code->count()) {
2030: locals_names=new ArrayString;
1.96 paf 2031: for(int i=0; i<size; i+=OPERATIONS_PER_OPVALUE) {
2032: const String* local_name=LA2S(*locals_names_code, i);
1.170 moko 2033: if(SYMBOLS_EQ(*local_name,RESULT_SYMBOL))
1.96 paf 2034: PC.explicit_result=true;
1.170 moko 2035: else if(SYMBOLS_EQ(*local_name,LOCALS_SYMBOL))
1.116 misha 2036: all_vars_local=true;
1.96 paf 2037: else
2038: *locals_names+=local_name;
2039: }
1.1 parser 2040: }
2041:
1.96 paf 2042: Method* method=new Method(
1.84 paf 2043: //name,
1.181 moko 2044: GetMethodCallType(PC, *yyvsp[-4]),
1.1 parser 2045: 0, 0/*min,max numbered_params_count*/,
2046: params_names, locals_names,
1.116 misha 2047: 0/*to be filled later in next {} */, 0, all_vars_local);
1.114 misha 2048:
1.181 moko 2049: *reinterpret_cast<Method**>(&yyval)=method;
1.158 misha 2050: }
1.197 ! moko 2051: #line 2052 "compile.tab.C"
1.112 paf 2052: break;
2053:
1.196 moko 2054: case 18: /* code_method: '@' STRING bracketed_maybe_strings maybe_bracketed_strings maybe_comment '\n' @1 maybe_codes */
1.197 ! moko 2055: #line 283 "compile.y"
1.196 moko 2056: {
1.181 moko 2057: Method* method=reinterpret_cast<Method*>(yyvsp[-1]);
1.124 misha 2058: // fill in the code
1.181 moko 2059: method->parser_code=yyvsp[0];
1.124 misha 2060:
2061: // register in class
1.181 moko 2062: const String& name=*LA2S(*yyvsp[-6]);
1.144 misha 2063: PC.cclass->set_method(PC.alias_method(name), method);
1.197 ! moko 2064: RECORD(METHOD, &PC.alias_method(name), method);
1.158 misha 2065: }
1.197 ! moko 2066: #line 2067 "compile.tab.C"
1.115 misha 2067: break;
2068:
1.196 moko 2069: case 21: /* bracketed_maybe_strings: '[' maybe_strings ']' */
1.197 ! moko 2070: #line 295 "compile.y"
1.196 moko 2071: {yyval=yyvsp[-1];}
1.197 ! moko 2072: #line 2073 "compile.tab.C"
1.112 paf 2073: break;
2074:
1.196 moko 2075: case 25: /* strings: strings ';' STRING */
1.197 ! moko 2076: #line 297 "compile.y"
1.196 moko 2077: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2078: #line 2079 "compile.tab.C"
1.112 paf 2079: break;
2080:
1.196 moko 2081: case 31: /* codes: codes code */
1.197 ! moko 2082: #line 305 "compile.y"
1.196 moko 2083: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2084: #line 2085 "compile.tab.C"
1.112 paf 2085: break;
2086:
1.196 moko 2087: case 37: /* get: get_value */
1.197 ! moko 2088: #line 311 "compile.y"
1.196 moko 2089: {
1.181 moko 2090: yyval=N();
2091: YYSTYPE code=yyvsp[0];
1.140 misha 2092: size_t count=code->count();
1.138 misha 2093:
1.128 misha 2094: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
1.171 moko 2095: if(count!=3 || !change_first(*code, OP::OP_VALUE__GET_ELEMENT, /*=>*/OP::OP_VALUE__GET_ELEMENT__WRITE) )
1.131 misha 2096: #endif
1.140 misha 2097:
1.138 misha 2098: #ifdef OPTIMIZE_BYTECODE_GET_SELF_ELEMENT
1.171 moko 2099: if(count!=3 || !change_first(*code, OP::OP_WITH_SELF__VALUE__GET_ELEMENT, /*=>*/OP::OP_WITH_SELF__VALUE__GET_ELEMENT__WRITE) )
1.138 misha 2100: #endif
2101:
1.132 misha 2102: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
1.171 moko 2103: if(count!=5 || !change_first(*code, OP::OP_GET_OBJECT_ELEMENT, /*=>*/OP::OP_GET_OBJECT_ELEMENT__WRITE) )
1.128 misha 2104: #endif
1.132 misha 2105:
2106: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
1.171 moko 2107: if(count!=5 || !change_first(*code, OP::OP_GET_OBJECT_VAR_ELEMENT, /*=>*/OP::OP_GET_OBJECT_VAR_ELEMENT__WRITE) )
1.131 misha 2108: #endif
1.159 misha 2109:
2110: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL
1.171 moko 2111: if(!change(*code, count-1/* last */, OP::OP_GET_ELEMENT__SPECIAL, /*=>*/OP::OP_GET_ELEMENT__SPECIAL__WRITE) )
1.159 misha 2112: #endif
2113:
1.140 misha 2114: {
1.171 moko 2115: 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 2116: }
1.140 misha 2117:
1.181 moko 2118: P(*yyval, *code);
1.158 misha 2119: }
1.197 ! moko 2120: #line 2121 "compile.tab.C"
1.112 paf 2121: break;
2122:
1.196 moko 2123: case 38: /* get_value: '$' get_name_value */
1.197 ! moko 2124: #line 342 "compile.y"
1.196 moko 2125: { yyval=yyvsp[0]; }
1.197 ! moko 2126: #line 2127 "compile.tab.C"
1.112 paf 2127: break;
2128:
1.196 moko 2129: case 41: /* name_in_curly_rdive: '{' name_without_curly_rdive '}' */
1.197 ! moko 2130: #line 344 "compile.y"
1.196 moko 2131: { yyval=yyvsp[-1]; }
1.197 ! moko 2132: #line 2133 "compile.tab.C"
1.112 paf 2133: break;
2134:
1.196 moko 2135: case 44: /* name_without_curly_rdive_read: name_without_curly_rdive_code */
1.197 ! moko 2136: #line 348 "compile.y"
1.196 moko 2137: {
1.181 moko 2138: yyval=N();
2139: YYSTYPE diving_code=yyvsp[0];
1.132 misha 2140: size_t count=diving_code->count();
1.140 misha 2141:
1.181 moko 2142: if(maybe_make_self(*yyval, *diving_code, count)) {
1.140 misha 2143: // $self.
2144: } else
1.132 misha 2145:
2146: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
1.181 moko 2147: if(maybe_make_get_object_element(*yyval, *diving_code, count)){
1.138 misha 2148: // optimization for $object.field + ^object.method[
1.140 misha 2149: } else
1.131 misha 2150: #endif
1.132 misha 2151:
2152: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
1.181 moko 2153: if(maybe_make_get_object_var_element(*yyval, *diving_code, count)){
1.138 misha 2154: // optimization for $object.$var
1.140 misha 2155: } else
1.131 misha 2156: #endif
1.132 misha 2157:
2158: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
1.171 moko 2159: if(count>=4 && (*diving_code)[0].code==OP::OP_VALUE && (*diving_code)[3].code==OP::OP_GET_ELEMENT ){
1.141 misha 2160: // optimization
1.181 moko 2161: O(*yyval,
1.140 misha 2162: (PC.in_call_value && count==4)
1.132 misha 2163: ? OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR // ^object[ : OP_VALUE+origin+string+OP_GET_ELEMENT => OP_VALUE__GET_ELEMENT_OR_OPERATOR+origin+string
2164: : OP::OP_VALUE__GET_ELEMENT // $object : OP_VALUE+origin+string+OP_GET_ELEMENT => OP_VALUE__GET_ELEMENT+origin+string
2165: );
1.181 moko 2166: P(*yyval, *diving_code, 1/*offset*/, 2/*limit*/); // copy origin+value
1.140 misha 2167: if(count>4)
1.181 moko 2168: P(*yyval, *diving_code, 4); // copy tail
1.132 misha 2169: } else {
1.181 moko 2170: O(*yyval, OP::OP_WITH_READ); /* stack: starting context */
2171: P(*yyval, *diving_code);
1.132 misha 2172: }
1.126 misha 2173: #else
1.140 misha 2174: {
1.181 moko 2175: O(*yyval, OP::OP_WITH_READ); /* stack: starting context */
1.37 paf 2176:
1.131 misha 2177: // ^if OP_ELEMENT => ^if OP_ELEMENT_OR_OPERATOR
2178: // optimized OP_VALUE+origin+string+OP_GET_ELEMENT. => OP_VALUE+origin+string+OP_GET_ELEMENT_OR_OPERATOR.
1.132 misha 2179: if(PC.in_call_value && count==4)
2180: diving_code->put(count-1, OP::OP_GET_ELEMENT_OR_OPERATOR);
1.181 moko 2181: P(*yyval, *diving_code);
1.132 misha 2182: }
1.126 misha 2183: #endif
1.1 parser 2184: /* diving code; stack: current context */
1.158 misha 2185: }
1.197 ! moko 2186: #line 2187 "compile.tab.C"
1.112 paf 2187: break;
2188:
1.196 moko 2189: case 45: /* name_without_curly_rdive_class: class_prefix name_without_curly_rdive_code */
1.197 ! moko 2190: #line 397 "compile.y"
1.196 moko 2191: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2192: #line 2193 "compile.tab.C"
1.112 paf 2193: break;
2194:
1.196 moko 2195: case 47: /* name_without_curly_rdive_code: name_path name_advance2 */
1.197 ! moko 2196: #line 398 "compile.y"
1.196 moko 2197: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2198: #line 2199 "compile.tab.C"
1.112 paf 2199: break;
2200:
1.196 moko 2201: case 48: /* put: '$' name_expr_wdive construct */
1.197 ! moko 2202: #line 402 "compile.y"
1.196 moko 2203: {
1.181 moko 2204: yyval=N();
1.137 misha 2205: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
1.181 moko 2206: if(maybe_optimize_construct(*yyval, *yyvsp[-1], *yyvsp[0])){
1.139 misha 2207: // $a(expr), $.a(expr), $a[value], $.a[value], $self.a[value], $self.a(expr)
1.134 misha 2208: } else
2209: #endif
2210: {
1.181 moko 2211: P(*yyval, *yyvsp[-1]); /* stack: context,name */
2212: P(*yyval, *yyvsp[0]); /* stack: context,name,constructor_value */
1.134 misha 2213: }
1.158 misha 2214: }
1.197 ! moko 2215: #line 2216 "compile.tab.C"
1.112 paf 2216: break;
2217:
1.196 moko 2218: case 52: /* name_expr_wdive_root: name_expr_dive_code */
1.197 ! moko 2219: #line 418 "compile.y"
1.196 moko 2220: {
1.181 moko 2221: yyval=N();
2222: YYSTYPE diving_code=yyvsp[0];
1.140 misha 2223: size_t count=diving_code->count();
2224:
1.181 moko 2225: if(maybe_make_self(*yyval, *diving_code, count)) {
1.140 misha 2226: // $self.
2227: } else
2228: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
1.171 moko 2229: if(count>=4 && (*diving_code)[0].code==OP::OP_VALUE && (*diving_code)[3].code==OP::OP_GET_ELEMENT ){
1.181 moko 2230: O(*yyval, OP::OP_WITH_ROOT__VALUE__GET_ELEMENT);
2231: P(*yyval, *diving_code, 1/*offset*/, 2/*limit*/); // copy origin+value
1.140 misha 2232: if(count>4)
1.181 moko 2233: P(*yyval, *diving_code, 4); // tail
1.140 misha 2234: } else
2235: #endif
2236: {
1.181 moko 2237: O(*yyval, OP::OP_WITH_ROOT); /* stack: starting context */
2238: P(*yyval, *diving_code);
1.1 parser 2239: }
2240: /* diving code; stack: current context */
1.158 misha 2241: }
1.197 ! moko 2242: #line 2243 "compile.tab.C"
1.112 paf 2243: break;
2244:
1.196 moko 2245: case 53: /* name_expr_wdive_write: '.' name_expr_dive_code */
1.197 ! moko 2246: #line 440 "compile.y"
1.196 moko 2247: {
1.181 moko 2248: yyval=N();
2249: O(*yyval, OP::OP_WITH_WRITE); /* stack: starting context */
2250: P(*yyval, *yyvsp[0]); /* diving code; stack: context,name */
1.158 misha 2251: }
1.197 ! moko 2252: #line 2253 "compile.tab.C"
1.112 paf 2253: break;
2254:
1.196 moko 2255: case 54: /* name_expr_wdive_class: class_prefix name_expr_dive_code */
1.197 ! moko 2256: #line 445 "compile.y"
1.196 moko 2257: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2258: #line 2259 "compile.tab.C"
1.112 paf 2259: break;
2260:
1.196 moko 2261: case 58: /* @2: %empty */
1.197 ! moko 2262: #line 452 "compile.y"
1.196 moko 2263: {
1.100 paf 2264: // allow $result_or_other_variable[ letters here any time ]
1.181 moko 2265: *reinterpret_cast<bool*>(&yyval)=PC.explicit_result; PC.explicit_result=false;
1.186 moko 2266: PC.array=false; // no need to save current value as if() is right after PC.array=true;
1.158 misha 2267: }
1.197 ! moko 2268: #line 2269 "compile.tab.C"
1.112 paf 2269: break;
2270:
1.196 moko 2271: case 59: /* $@3: %empty */
1.197 ! moko 2272: #line 456 "compile.y"
1.196 moko 2273: {
1.181 moko 2274: PC.explicit_result=*reinterpret_cast<bool*>(&yyvsp[-1]);
1.158 misha 2275: }
1.197 ! moko 2276: #line 2277 "compile.tab.C"
1.112 paf 2277: break;
2278:
1.196 moko 2279: case 60: /* construct_square: '[' @2 any_constructor_code_values $@3 ']' */
1.197 ! moko 2280: #line 458 "compile.y"
1.196 moko 2281: {
1.1 parser 2282: // stack: context, name
1.186 moko 2283: if(!PC.array){
2284: yyval=yyvsp[-2]; // stack: context, name, value
2285: O(*yyval, OP::OP_CONSTRUCT_VALUE); /* value=pop; name=pop; context=pop; construct(context,name,value) */
2286: } else {
2287: yyval = N();
2288: OA(*yyval, OP::OP_CONSTRUCT_ARRAY, yyvsp[-2]);
2289: PC.array=false;
2290: }
1.158 misha 2291: }
1.197 ! moko 2292: #line 2293 "compile.tab.C"
1.112 paf 2293: break;
2294:
1.196 moko 2295: case 61: /* any_constructor_code_values: any_constructor_code_value */
1.197 ! moko 2296: #line 471 "compile.y"
1.196 moko 2297: { yyval = yyvsp[0]; }
1.197 ! moko 2298: #line 2299 "compile.tab.C"
1.186 moko 2299: break;
2300:
1.196 moko 2301: case 62: /* any_constructor_code_values: any_constructor_code_values ';' any_constructor_code_value */
1.197 ! moko 2302: #line 472 "compile.y"
1.196 moko 2303: { yyval = yyvsp[-2]; P(*yyval, *yyvsp[0]); PC.array=true; }
1.197 ! moko 2304: #line 2305 "compile.tab.C"
1.186 moko 2305: break;
2306:
1.196 moko 2307: case 63: /* construct_round: '(' expr_value ')' */
1.197 ! moko 2308: #line 474 "compile.y"
1.196 moko 2309: {
1.181 moko 2310: yyval=N();
1.1 parser 2311: // stack: context, name
1.181 moko 2312: P(*yyval, *yyvsp[-1]); // stack: context, name, value
2313: O(*yyval, OP::OP_CONSTRUCT_EXPR); /* value=pop->as_expr_result; name=pop; context=pop; construct(context,name,value) */
1.158 misha 2314: }
1.197 ! moko 2315: #line 2316 "compile.tab.C"
1.112 paf 2316: break;
2317:
1.196 moko 2318: case 64: /* construct_curly: '{' maybe_codes '}' */
1.197 ! moko 2319: #line 481 "compile.y"
1.196 moko 2320: {
1.1 parser 2321: // stack: context, name
1.181 moko 2322: yyval=N();
2323: OA(*yyval, OP::OP_CURLY_CODE__CONSTRUCT, yyvsp[-1]); /* code=pop; name=pop; context=pop; construct(context,name,junction(code)) */
1.158 misha 2324: }
1.197 ! moko 2325: #line 2326 "compile.tab.C"
1.112 paf 2326: break;
2327:
1.196 moko 2328: case 68: /* constructor_code_value: constructor_code */
1.197 ! moko 2329: #line 492 "compile.y"
1.196 moko 2330: {
1.181 moko 2331: yyval=N();
2332: OA(*yyval, OP::OP_OBJECT_POOL, yyvsp[0]); /* stack: empty write context */
1.47 paf 2333: /* some code that writes to that context */
2334: /* context=pop; stack: context.value() */
1.158 misha 2335: }
1.197 ! moko 2336: #line 2337 "compile.tab.C"
1.112 paf 2337: break;
2338:
1.196 moko 2339: case 71: /* codes__excluding_sole_str_literal: code codes */
1.197 ! moko 2340: #line 499 "compile.y"
1.196 moko 2341: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2342: #line 2343 "compile.tab.C"
1.112 paf 2343: break;
2344:
1.196 moko 2345: case 72: /* call: call_value */
1.197 ! moko 2346: #line 503 "compile.y"
1.196 moko 2347: {
1.181 moko 2348: size_t count=yyvsp[0]->count();
1.131 misha 2349: #ifdef OPTIMIZE_BYTECODE_CUT_REM_OPERATOR
1.159 misha 2350: if(count)
1.131 misha 2351: #endif
2352: {
1.181 moko 2353: yyval=yyvsp[0]; /* stack: value */
2354: if(!change_first(*yyval, OP::OP_CONSTRUCT_OBJECT, /*=>*/ OP::OP_CONSTRUCT_OBJECT__WRITE))
2355: 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 2356: }
1.158 misha 2357: }
1.197 ! moko 2358: #line 2359 "compile.tab.C"
1.112 paf 2359: break;
2360:
1.196 moko 2361: case 73: /* $@4: %empty */
1.197 ! moko 2362: #line 514 "compile.y"
1.196 moko 2363: {
1.171 moko 2364: PC.in_call_value=true;
2365: }
1.197 ! moko 2366: #line 2367 "compile.tab.C"
1.112 paf 2367: break;
2368:
1.196 moko 2369: case 74: /* $@5: %empty */
1.197 ! moko 2370: #line 517 "compile.y"
1.196 moko 2371: {
1.171 moko 2372: PC.in_call_value=false;
2373: }
1.197 ! moko 2374: #line 2375 "compile.tab.C"
1.112 paf 2375: break;
2376:
1.196 moko 2377: case 75: /* call_value: '^' $@4 call_name $@5 store_params EON */
1.197 ! moko 2378: #line 520 "compile.y"
1.196 moko 2379: { /* ^field.$method{vasya} */
1.131 misha 2380: #ifdef OPTIMIZE_BYTECODE_CUT_REM_OPERATOR
1.135 misha 2381: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
1.181 moko 2382: const String* operator_name=LA2S(*yyvsp[-3], 0, OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR);
1.135 misha 2383: #else
1.181 moko 2384: const String* operator_name=LA2S(*yyvsp[-3], 1);
1.135 misha 2385: #endif
1.170 moko 2386: if(operator_name && SYMBOLS_EQ(*operator_name,REM_SYMBOL)){
1.181 moko 2387: yyval=N();
1.131 misha 2388: } else
2389: #endif
2390: {
1.181 moko 2391: YYSTYPE params_code=yyvsp[-1];
1.131 misha 2392: if(params_code->count()==3) { // probably [] case. [OP::OP_VALUE+origin+Void]
2393: if(Value* value=LA2V(*params_code)) // it is OP_VALUE+origin+value?
1.153 moko 2394: if(const String * string=value->get_string())
2395: if(string->is_empty()) // value is empty string?
2396: params_code=0; // ^zzz[] case. don't append lone empty param.
1.131 misha 2397: }
2398: /* stack: context, method_junction */
1.142 misha 2399:
1.181 moko 2400: YYSTYPE var_code=yyvsp[-3];
1.142 misha 2401: if(
2402: var_code->count()==8
1.172 moko 2403: && ( (*var_code)[0].code==OP::OP_VALUE__GET_CLASS || (*var_code)[0].code==OP::OP_VALUE__GET_BASE_CLASS )
1.142 misha 2404: && (*var_code)[3].code==OP::OP_PREPARE_TO_CONSTRUCT_OBJECT
2405: && (*var_code)[4].code==OP::OP_VALUE
1.164 moko 2406: #ifdef FEATURE_GET_ELEMENT4CALL
2407: && (*var_code)[7].code==OP::OP_GET_ELEMENT4CALL
2408: #else
1.142 misha 2409: && (*var_code)[7].code==OP::OP_GET_ELEMENT
1.164 moko 2410: #endif
1.142 misha 2411: ){
1.181 moko 2412: yyval=N();
2413: O(*yyval, OP::OP_CONSTRUCT_OBJECT);
2414: P(*yyval, *var_code, 1/*offset*/, 2/*limit*/); // class name
2415: P(*yyval, *var_code, 5/*offset*/, 2/*limit*/); // constructor name
2416: OA(*yyval, params_code);
1.142 misha 2417: } else
2418: {
1.181 moko 2419: yyval=var_code; /* with_xxx,diving code; stack: context,method_junction */
2420: OA(*yyval, OP::OP_CALL, params_code); // method_frame=make frame(pop junction); ncontext=pop; call(ncontext,method_frame) stack: value
1.142 misha 2421: }
1.131 misha 2422: }
1.158 misha 2423: }
1.197 ! moko 2424: #line 2425 "compile.tab.C"
1.164 moko 2425: break;
2426:
1.196 moko 2427: case 76: /* call_name: name_without_curly_rdive */
1.197 ! moko 2428: #line 566 "compile.y"
1.196 moko 2429: {
1.164 moko 2430: #ifdef FEATURE_GET_ELEMENT4CALL
1.181 moko 2431: size_t count=yyvsp[0]->count();
1.164 moko 2432: if(count){
1.181 moko 2433: yyval=yyvsp[0];
1.164 moko 2434: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
1.181 moko 2435: !(count==5 && change_first(*yyval, OP::OP_GET_OBJECT_ELEMENT, OP::OP_GET_OBJECT_ELEMENT4CALL)) &&
1.164 moko 2436: #endif
2437: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
1.181 moko 2438: !(count==5 && change_first(*yyval, OP::OP_GET_OBJECT_VAR_ELEMENT, OP::OP_GET_OBJECT_VAR_ELEMENT4CALL)) &&
1.164 moko 2439: #endif
1.181 moko 2440: !change(*yyval, count-1, OP::OP_GET_ELEMENT, OP::OP_GET_ELEMENT4CALL);
1.164 moko 2441: }
2442: #endif
2443: }
1.197 ! moko 2444: #line 2445 "compile.tab.C"
1.112 paf 2445: break;
2446:
1.196 moko 2447: case 78: /* store_params: store_params store_param */
1.197 ! moko 2448: #line 582 "compile.y"
1.196 moko 2449: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2450: #line 2451 "compile.tab.C"
1.112 paf 2451: break;
2452:
1.196 moko 2453: case 82: /* @6: %empty */
1.197 ! moko 2454: #line 588 "compile.y"
1.196 moko 2455: {
1.100 paf 2456: // allow ^call[ letters here any time ]
1.181 moko 2457: *reinterpret_cast<bool*>(&yyval)=PC.explicit_result; PC.explicit_result=false;
1.158 misha 2458: }
1.197 ! moko 2459: #line 2460 "compile.tab.C"
1.112 paf 2460: break;
2461:
1.196 moko 2462: case 83: /* $@7: %empty */
1.197 ! moko 2463: #line 591 "compile.y"
1.196 moko 2464: {
1.181 moko 2465: PC.explicit_result=*reinterpret_cast<bool*>(&yyvsp[-1]);
1.158 misha 2466: }
1.197 ! moko 2467: #line 2468 "compile.tab.C"
1.112 paf 2468: break;
2469:
1.196 moko 2470: case 84: /* store_square_param: '[' @6 store_code_param_parts $@7 ']' */
1.197 ! moko 2471: #line 593 "compile.y"
1.196 moko 2472: {yyval=yyvsp[-2];}
1.197 ! moko 2473: #line 2474 "compile.tab.C"
1.112 paf 2474: break;
2475:
1.196 moko 2476: case 85: /* store_round_param: '(' store_expr_param_parts ')' */
1.197 ! moko 2477: #line 594 "compile.y"
1.196 moko 2478: {yyval=yyvsp[-1];}
1.197 ! moko 2479: #line 2480 "compile.tab.C"
1.112 paf 2480: break;
2481:
1.196 moko 2482: case 86: /* store_curly_param: '{' store_curly_param_parts '}' */
1.197 ! moko 2483: #line 595 "compile.y"
1.196 moko 2484: {yyval=yyvsp[-1];}
1.197 ! moko 2485: #line 2486 "compile.tab.C"
1.112 paf 2486: break;
2487:
1.196 moko 2488: case 88: /* store_code_param_parts: store_code_param_parts ';' store_code_param_part */
1.197 ! moko 2489: #line 598 "compile.y"
1.196 moko 2490: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2491: #line 2492 "compile.tab.C"
1.112 paf 2492: break;
2493:
1.196 moko 2494: case 90: /* store_expr_param_parts: store_expr_param_parts ';' store_expr_param_part */
1.197 ! moko 2495: #line 602 "compile.y"
1.196 moko 2496: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2497: #line 2498 "compile.tab.C"
1.112 paf 2498: break;
2499:
1.196 moko 2500: case 92: /* store_curly_param_parts: store_curly_param_parts ';' store_curly_param_part */
1.197 ! moko 2501: #line 606 "compile.y"
1.196 moko 2502: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2503: #line 2504 "compile.tab.C"
1.112 paf 2504: break;
2505:
1.196 moko 2506: case 93: /* store_code_param_part: code_param_value */
1.197 ! moko 2507: #line 608 "compile.y"
1.196 moko 2508: {
1.181 moko 2509: yyval=yyvsp[0];
1.158 misha 2510: }
1.197 ! moko 2511: #line 2512 "compile.tab.C"
1.112 paf 2512: break;
2513:
1.196 moko 2514: case 94: /* store_expr_param_part: expr_value */
1.197 ! moko 2515: #line 611 "compile.y"
1.196 moko 2516: {
1.181 moko 2517: YYSTYPE expr_code=yyvsp[0];
1.106 paf 2518: if(expr_code->count()==3
1.127 misha 2519: && (*expr_code)[0].code==OP::OP_VALUE) { // optimizing (double/bool/incidently 'string' too) case. [OP::OP_VALUE+origin+Double]. no evaluating
1.181 moko 2520: yyval=expr_code;
1.104 paf 2521: } else {
1.131 misha 2522: YYSTYPE code=N();
1.104 paf 2523: P(*code, *expr_code);
1.122 misha 2524: O(*code, OP::OP_WRITE_EXPR_RESULT);
1.181 moko 2525: yyval=N();
2526: OA(*yyval, OP::OP_EXPR_CODE__STORE_PARAM, code);
1.104 paf 2527: }
1.158 misha 2528: }
1.197 ! moko 2529: #line 2530 "compile.tab.C"
1.112 paf 2530: break;
2531:
1.196 moko 2532: case 95: /* store_curly_param_part: maybe_codes */
1.197 ! moko 2533: #line 624 "compile.y"
1.196 moko 2534: {
1.181 moko 2535: yyval=N();
2536: OA(*yyval, OP::OP_CURLY_CODE__STORE_PARAM, yyvsp[0]);
1.158 misha 2537: }
1.197 ! moko 2538: #line 2539 "compile.tab.C"
1.112 paf 2539: break;
2540:
1.196 moko 2541: case 100: /* name_expr_dive_code: name_path name_expr_value */
1.197 ! moko 2542: #line 636 "compile.y"
1.196 moko 2543: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2544: #line 2545 "compile.tab.C"
1.112 paf 2545: break;
2546:
1.196 moko 2547: case 102: /* name_path: name_path name_step */
1.197 ! moko 2548: #line 638 "compile.y"
1.196 moko 2549: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2550: #line 2551 "compile.tab.C"
1.112 paf 2551: break;
2552:
1.196 moko 2553: case 104: /* name_advance1: name_expr_value */
1.197 ! moko 2554: #line 640 "compile.y"
1.196 moko 2555: {
1.33 paf 2556: // we know that name_advance1 not called from ^xxx context
2557: // so we'll not check for operator call possibility as we do in name_advance2
2558:
1.1 parser 2559: /* stack: context */
1.181 moko 2560: yyval=yyvsp[0]; /* stack: context,name */
1.159 misha 2561: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL
1.181 moko 2562: O(*yyval, is_special_element(*yyval) ? OP::OP_GET_ELEMENT__SPECIAL : OP::OP_GET_ELEMENT);
1.159 misha 2563: #else
1.181 moko 2564: O(*yyval, OP::OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */
1.159 misha 2565: #endif
1.158 misha 2566: }
1.197 ! moko 2567: #line 2568 "compile.tab.C"
1.112 paf 2568: break;
2569:
1.196 moko 2570: case 105: /* name_advance2: name_expr_value */
1.197 ! moko 2571: #line 652 "compile.y"
1.196 moko 2572: {
1.1 parser 2573: /* stack: context */
1.181 moko 2574: yyval=yyvsp[0]; /* stack: context,name */
1.159 misha 2575: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL
1.181 moko 2576: O(*yyval, is_special_element(*yyval) ? OP::OP_GET_ELEMENT__SPECIAL : OP::OP_GET_ELEMENT);
1.159 misha 2577: #else
1.181 moko 2578: O(*yyval, OP::OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */
1.159 misha 2579: #endif
1.158 misha 2580: }
1.197 ! moko 2581: #line 2582 "compile.tab.C"
1.112 paf 2582: break;
2583:
1.196 moko 2584: case 112: /* name_expr_subvar_value: '$' subvar_ref_name_rdive */
1.197 ! moko 2585: #line 670 "compile.y"
1.196 moko 2586: {
1.181 moko 2587: yyval=yyvsp[0];
2588: O(*yyval, OP::OP_GET_ELEMENT);
1.158 misha 2589: }
1.197 ! moko 2590: #line 2591 "compile.tab.C"
1.112 paf 2591: break;
2592:
1.196 moko 2593: case 113: /* name_expr_with_subvar_value: STRING subvar_get_writes */
1.197 ! moko 2594: #line 674 "compile.y"
1.196 moko 2595: {
1.131 misha 2596: YYSTYPE code;
1.47 paf 2597: {
1.181 moko 2598: change_string_literal_to_write_string_literal(*(code=yyvsp[-1]));
2599: P(*code, *yyvsp[0]);
1.47 paf 2600: }
1.181 moko 2601: yyval=N();
2602: OA(*yyval, OP::OP_STRING_POOL, code);
1.158 misha 2603: }
1.197 ! moko 2604: #line 2605 "compile.tab.C"
1.112 paf 2605: break;
2606:
1.196 moko 2607: case 114: /* @8: %empty */
1.197 ! moko 2608: #line 683 "compile.y"
1.196 moko 2609: {
1.100 paf 2610: // allow $result_or_other_variable[ letters here any time ]
1.181 moko 2611: *reinterpret_cast<bool*>(&yyval)=PC.explicit_result; PC.explicit_result=false;
1.158 misha 2612: }
1.197 ! moko 2613: #line 2614 "compile.tab.C"
1.112 paf 2614: break;
2615:
1.196 moko 2616: case 115: /* $@9: %empty */
1.197 ! moko 2617: #line 686 "compile.y"
1.196 moko 2618: {
1.181 moko 2619: PC.explicit_result=*reinterpret_cast<bool*>(&yyvsp[-1]);
1.158 misha 2620: }
1.197 ! moko 2621: #line 2622 "compile.tab.C"
1.112 paf 2622: break;
2623:
1.196 moko 2624: case 116: /* name_square_code_value: '[' @8 codes $@9 ']' */
1.197 ! moko 2625: #line 688 "compile.y"
1.196 moko 2626: {
1.191 moko 2627: yyval=N();
2628: if(!maybe_append_simple_diving_code(*yyval, *yyvsp[-2])) {
1.181 moko 2629: OA(*yyval, OP::OP_OBJECT_POOL, yyvsp[-2]); /* stack: empty write context */
1.171 moko 2630: /* some code that writes to that context */
2631: /* context=pop; stack: context.value() */
1.159 misha 2632: }
1.158 misha 2633: }
1.197 ! moko 2634: #line 2635 "compile.tab.C"
1.190 moko 2635: break;
2636:
1.196 moko 2637: case 117: /* name_round_expr_value: '(' expr_value ')' */
1.197 ! moko 2638: #line 696 "compile.y"
1.196 moko 2639: {
1.190 moko 2640: yyval = N();
2641: P(*yyval, *yyvsp[-1]);
2642: }
1.197 ! moko 2643: #line 2644 "compile.tab.C"
1.112 paf 2644: break;
2645:
1.196 moko 2646: case 118: /* subvar_ref_name_rdive: STRING */
1.197 ! moko 2647: #line 700 "compile.y"
1.196 moko 2648: {
1.181 moko 2649: yyval=N();
2650: O(*yyval, OP::OP_WITH_READ);
2651: P(*yyval, *yyvsp[0]);
1.158 misha 2652: }
1.197 ! moko 2653: #line 2654 "compile.tab.C"
1.112 paf 2654: break;
2655:
1.196 moko 2656: case 120: /* subvar_get_writes: subvar_get_writes subvar__get_write */
1.197 ! moko 2657: #line 705 "compile.y"
1.196 moko 2658: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]); }
1.197 ! moko 2659: #line 2660 "compile.tab.C"
1.112 paf 2660: break;
2661:
1.196 moko 2662: case 121: /* subvar__get_write: '$' subvar_ref_name_rdive */
1.197 ! moko 2663: #line 706 "compile.y"
1.196 moko 2664: {
1.181 moko 2665: yyval=yyvsp[0];
2666: O(*yyval, OP::OP_GET_ELEMENT__WRITE);
1.158 misha 2667: }
1.197 ! moko 2668: #line 2669 "compile.tab.C"
1.112 paf 2669: break;
2670:
1.196 moko 2671: case 124: /* class_static_prefix: STRING ':' */
1.197 ! moko 2672: #line 715 "compile.y"
1.196 moko 2673: {
1.181 moko 2674: yyval=yyvsp[-1]; // stack: class name string
1.172 moko 2675: OP::OPCODE code = OP::OP_VALUE__GET_CLASS;
1.181 moko 2676: if(*LA2S(*yyval) == BASE_NAME) { // pseudo BASE class
1.84 paf 2677: if(VStateless_class* base=PC.cclass->base_class()) {
1.181 moko 2678: change_string_literal_value(*yyval, *new String(base->type()));
1.61 paf 2679: } else {
1.181 moko 2680: YYERROR1("no base class declared");
1.61 paf 2681: }
1.172 moko 2682: code = OP::OP_VALUE__GET_BASE_CLASS;
2683: } else {
1.173 moko 2684: // can't use get_class because it will call @autouse[] if the class wasn't loaded
1.181 moko 2685: VStateless_class* base=PC.request.classes().get(*LA2S(*yyval));
1.173 moko 2686: if(base && PC.cclass->derived_from(*base))
1.172 moko 2687: code = OP::OP_VALUE__GET_BASE_CLASS;
1.61 paf 2688: }
1.131 misha 2689: // optimized OP_VALUE+origin+string+OP_GET_CLASS => OP_VALUE__GET_CLASS+origin+string
1.181 moko 2690: change_first(*yyval, OP::OP_VALUE, code);
1.158 misha 2691: }
1.197 ! moko 2692: #line 2693 "compile.tab.C"
1.112 paf 2693: break;
2694:
1.196 moko 2695: case 125: /* class_constructor_prefix: class_static_prefix ':' */
1.197 ! moko 2696: #line 734 "compile.y"
1.196 moko 2697: {
1.181 moko 2698: yyval=yyvsp[-1];
2699: if(!PC.in_call_value)
2700: YYERROR1(":: not allowed here");
2701: O(*yyval, OP::OP_PREPARE_TO_CONSTRUCT_OBJECT);
1.158 misha 2702: }
1.197 ! moko 2703: #line 2704 "compile.tab.C"
1.112 paf 2704: break;
2705:
1.196 moko 2706: case 132: /* expr: '"' string_inside_quotes_value '"' */
1.197 ! moko 2707: #line 751 "compile.y"
1.196 moko 2708: { yyval = yyvsp[-1]; }
1.197 ! moko 2709: #line 2710 "compile.tab.C"
1.114 misha 2710: break;
2711:
1.196 moko 2712: case 133: /* expr: '\'' string_inside_quotes_value '\'' */
1.197 ! moko 2713: #line 752 "compile.y"
1.196 moko 2714: { yyval = yyvsp[-1]; }
1.197 ! moko 2715: #line 2716 "compile.tab.C"
1.112 paf 2716: break;
2717:
1.196 moko 2718: case 134: /* expr: '(' expr ')' */
1.197 ! moko 2719: #line 753 "compile.y"
1.196 moko 2720: { yyval = yyvsp[-1]; }
1.197 ! moko 2721: #line 2722 "compile.tab.C"
1.112 paf 2722: break;
2723:
1.196 moko 2724: case 135: /* expr: '-' expr */
1.197 ! moko 2725: #line 755 "compile.y"
1.196 moko 2726: { yyval=yyvsp[0]; O(*yyval, OP::OP_NEG); }
1.197 ! moko 2727: #line 2728 "compile.tab.C"
1.112 paf 2728: break;
2729:
1.196 moko 2730: case 136: /* expr: '+' expr */
1.197 ! moko 2731: #line 756 "compile.y"
1.196 moko 2732: { yyval=yyvsp[0]; }
1.197 ! moko 2733: #line 2734 "compile.tab.C"
1.112 paf 2734: break;
2735:
1.196 moko 2736: case 137: /* expr: '~' expr */
1.197 ! moko 2737: #line 757 "compile.y"
1.196 moko 2738: { yyval=yyvsp[0]; O(*yyval, OP::OP_INV); }
1.197 ! moko 2739: #line 2740 "compile.tab.C"
1.112 paf 2740: break;
2741:
1.196 moko 2742: case 138: /* expr: '!' expr */
1.197 ! moko 2743: #line 758 "compile.y"
1.196 moko 2744: { yyval=yyvsp[0]; O(*yyval, OP::OP_NOT); }
1.197 ! moko 2745: #line 2746 "compile.tab.C"
1.112 paf 2746: break;
2747:
1.196 moko 2748: case 139: /* expr: "def" expr */
1.197 ! moko 2749: #line 759 "compile.y"
1.196 moko 2750: { yyval=yyvsp[0]; O(*yyval, OP::OP_DEF); }
1.197 ! moko 2751: #line 2752 "compile.tab.C"
1.112 paf 2752: break;
2753:
1.196 moko 2754: case 140: /* expr: "in" expr */
1.197 ! moko 2755: #line 760 "compile.y"
1.196 moko 2756: { yyval=yyvsp[0]; O(*yyval, OP::OP_IN); }
1.197 ! moko 2757: #line 2758 "compile.tab.C"
1.112 paf 2758: break;
2759:
1.196 moko 2760: case 141: /* expr: "-f" expr */
1.197 ! moko 2761: #line 761 "compile.y"
1.196 moko 2762: { yyval=yyvsp[0]; O(*yyval, OP::OP_FEXISTS); }
1.197 ! moko 2763: #line 2764 "compile.tab.C"
1.112 paf 2764: break;
2765:
1.196 moko 2766: case 142: /* expr: "-d" expr */
1.197 ! moko 2767: #line 762 "compile.y"
1.196 moko 2768: { yyval=yyvsp[0]; O(*yyval, OP::OP_DEXISTS); }
1.197 ! moko 2769: #line 2770 "compile.tab.C"
1.112 paf 2770: break;
2771:
1.196 moko 2772: case 143: /* expr: expr '-' expr */
1.197 ! moko 2773: #line 764 "compile.y"
1.196 moko 2774: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_SUB); }
1.197 ! moko 2775: #line 2776 "compile.tab.C"
1.112 paf 2776: break;
2777:
1.196 moko 2778: case 144: /* expr: expr '+' expr */
1.197 ! moko 2779: #line 765 "compile.y"
1.196 moko 2780: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_ADD); }
1.197 ! moko 2781: #line 2782 "compile.tab.C"
1.112 paf 2782: break;
2783:
1.196 moko 2784: case 145: /* expr: expr '*' expr */
1.197 ! moko 2785: #line 766 "compile.y"
1.196 moko 2786: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_MUL); }
1.197 ! moko 2787: #line 2788 "compile.tab.C"
1.112 paf 2788: break;
2789:
1.196 moko 2790: case 146: /* expr: expr '/' expr */
1.197 ! moko 2791: #line 767 "compile.y"
1.196 moko 2792: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_DIV); }
1.197 ! moko 2793: #line 2794 "compile.tab.C"
1.112 paf 2794: break;
2795:
1.196 moko 2796: case 147: /* expr: expr '%' expr */
1.197 ! moko 2797: #line 768 "compile.y"
1.196 moko 2798: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_MOD); }
1.197 ! moko 2799: #line 2800 "compile.tab.C"
1.112 paf 2800: break;
2801:
1.196 moko 2802: case 148: /* expr: expr '\\' expr */
1.197 ! moko 2803: #line 769 "compile.y"
1.196 moko 2804: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_INTDIV); }
1.197 ! moko 2805: #line 2806 "compile.tab.C"
1.112 paf 2806: break;
2807:
1.196 moko 2808: case 149: /* expr: expr "<<" expr */
1.197 ! moko 2809: #line 770 "compile.y"
1.196 moko 2810: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_SL); }
1.197 ! moko 2811: #line 2812 "compile.tab.C"
1.112 paf 2812: break;
2813:
1.196 moko 2814: case 150: /* expr: expr ">>" expr */
1.197 ! moko 2815: #line 771 "compile.y"
1.196 moko 2816: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_SR); }
1.197 ! moko 2817: #line 2818 "compile.tab.C"
1.112 paf 2818: break;
2819:
1.196 moko 2820: case 151: /* expr: expr '&' expr */
1.197 ! moko 2821: #line 772 "compile.y"
1.196 moko 2822: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_AND); }
1.197 ! moko 2823: #line 2824 "compile.tab.C"
1.112 paf 2824: break;
2825:
1.196 moko 2826: case 152: /* expr: expr '|' expr */
1.197 ! moko 2827: #line 773 "compile.y"
1.196 moko 2828: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_OR); }
1.197 ! moko 2829: #line 2830 "compile.tab.C"
1.112 paf 2830: break;
2831:
1.196 moko 2832: case 153: /* expr: expr "!|" expr */
1.197 ! moko 2833: #line 774 "compile.y"
1.196 moko 2834: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_XOR); }
1.197 ! moko 2835: #line 2836 "compile.tab.C"
1.112 paf 2836: break;
2837:
1.196 moko 2838: case 154: /* expr: expr "&&" expr */
1.197 ! moko 2839: #line 775 "compile.y"
1.196 moko 2840: { yyval=yyvsp[-2]; OA(*yyval, OP::OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP::OP_LOG_AND); }
1.197 ! moko 2841: #line 2842 "compile.tab.C"
1.112 paf 2842: break;
2843:
1.196 moko 2844: case 155: /* expr: expr "||" expr */
1.197 ! moko 2845: #line 776 "compile.y"
1.196 moko 2846: { yyval=yyvsp[-2]; OA(*yyval, OP::OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP::OP_LOG_OR); }
1.197 ! moko 2847: #line 2848 "compile.tab.C"
1.112 paf 2848: break;
2849:
1.196 moko 2850: case 156: /* expr: expr "!||" expr */
1.197 ! moko 2851: #line 777 "compile.y"
1.196 moko 2852: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_LOG_XOR); }
1.197 ! moko 2853: #line 2854 "compile.tab.C"
1.112 paf 2854: break;
2855:
1.196 moko 2856: case 157: /* expr: expr '<' expr */
1.197 ! moko 2857: #line 778 "compile.y"
1.196 moko 2858: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_LT); }
1.197 ! moko 2859: #line 2860 "compile.tab.C"
1.112 paf 2860: break;
2861:
1.196 moko 2862: case 158: /* expr: expr '>' expr */
1.197 ! moko 2863: #line 779 "compile.y"
1.196 moko 2864: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_GT); }
1.197 ! moko 2865: #line 2866 "compile.tab.C"
1.112 paf 2866: break;
2867:
1.196 moko 2868: case 159: /* expr: expr "<=" expr */
1.197 ! moko 2869: #line 780 "compile.y"
1.196 moko 2870: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_LE); }
1.197 ! moko 2871: #line 2872 "compile.tab.C"
1.112 paf 2872: break;
2873:
1.196 moko 2874: case 160: /* expr: expr ">=" expr */
1.197 ! moko 2875: #line 781 "compile.y"
1.196 moko 2876: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_GE); }
1.197 ! moko 2877: #line 2878 "compile.tab.C"
1.112 paf 2878: break;
2879:
1.196 moko 2880: case 161: /* expr: expr "==" expr */
1.197 ! moko 2881: #line 782 "compile.y"
1.196 moko 2882: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_EQ); }
1.197 ! moko 2883: #line 2884 "compile.tab.C"
1.112 paf 2884: break;
2885:
1.196 moko 2886: case 162: /* expr: expr "!=" expr */
1.197 ! moko 2887: #line 783 "compile.y"
1.196 moko 2888: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_NE); }
1.197 ! moko 2889: #line 2890 "compile.tab.C"
1.112 paf 2890: break;
2891:
1.196 moko 2892: case 163: /* expr: expr "lt" expr */
1.197 ! moko 2893: #line 784 "compile.y"
1.196 moko 2894: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_LT); }
1.197 ! moko 2895: #line 2896 "compile.tab.C"
1.112 paf 2896: break;
2897:
1.196 moko 2898: case 164: /* expr: expr "gt" expr */
1.197 ! moko 2899: #line 785 "compile.y"
1.196 moko 2900: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_GT); }
1.197 ! moko 2901: #line 2902 "compile.tab.C"
1.112 paf 2902: break;
2903:
1.196 moko 2904: case 165: /* expr: expr "le" expr */
1.197 ! moko 2905: #line 786 "compile.y"
1.196 moko 2906: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_LE); }
1.197 ! moko 2907: #line 2908 "compile.tab.C"
1.112 paf 2908: break;
2909:
1.196 moko 2910: case 166: /* expr: expr "ge" expr */
1.197 ! moko 2911: #line 787 "compile.y"
1.196 moko 2912: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_GE); }
1.197 ! moko 2913: #line 2914 "compile.tab.C"
1.112 paf 2914: break;
2915:
1.196 moko 2916: case 167: /* expr: expr "eq" expr */
1.197 ! moko 2917: #line 788 "compile.y"
1.196 moko 2918: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_EQ); }
1.197 ! moko 2919: #line 2920 "compile.tab.C"
1.112 paf 2920: break;
2921:
1.196 moko 2922: case 168: /* expr: expr "ne" expr */
1.197 ! moko 2923: #line 789 "compile.y"
1.196 moko 2924: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_NE); }
1.197 ! moko 2925: #line 2926 "compile.tab.C"
1.112 paf 2926: break;
2927:
1.196 moko 2928: case 169: /* expr: expr "is" expr */
1.197 ! moko 2929: #line 790 "compile.y"
1.196 moko 2930: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_IS); }
1.197 ! moko 2931: #line 2932 "compile.tab.C"
1.112 paf 2932: break;
2933:
1.196 moko 2934: case 170: /* double_or_STRING: STRING */
1.197 ! moko 2935: #line 793 "compile.y"
1.196 moko 2936: {
1.131 misha 2937: // optimized OP_STRING => OP_VALUE for doubles
1.181 moko 2938: maybe_change_string_literal_to_double_literal(*(yyval=yyvsp[0]));
1.158 misha 2939: }
1.197 ! moko 2940: #line 2941 "compile.tab.C"
1.112 paf 2941: break;
2942:
1.196 moko 2943: case 171: /* string_inside_quotes_value: maybe_codes */
1.197 ! moko 2944: #line 798 "compile.y"
1.196 moko 2945: {
1.131 misha 2946: #ifdef OPTIMIZE_BYTECODE_STRING_POOL
2947: // it brakes ^if(" 09 "){...}
1.181 moko 2948: YYSTYPE code=yyvsp[0];
2949: yyval=N();
1.159 misha 2950: if(code->count()==3 && change_first(*code, OP::OP_STRING__WRITE, OP::OP_VALUE)){
1.131 misha 2951: // optimized OP_STRING__WRITE+origin+value => OP_VALUE+origin+value without starting OP_STRING_POOL
1.181 moko 2952: P(*yyval, *code);
1.131 misha 2953: } else {
1.181 moko 2954: OA(*yyval, OP::OP_STRING_POOL, code); /* stack: empty write context */
1.131 misha 2955: }
2956: #else
1.181 moko 2957: yyval=N();
2958: OA(*yyval, OP::OP_STRING_POOL, yyvsp[0]); /* stack: empty write context */
1.131 misha 2959: #endif
1.47 paf 2960: /* some code that writes to that context */
2961: /* context=pop; stack: context.get_string() */
1.158 misha 2962: }
1.197 ! moko 2963: #line 2964 "compile.tab.C"
1.112 paf 2964: break;
2965:
1.196 moko 2966: case 172: /* write_string: STRING */
1.197 ! moko 2967: #line 819 "compile.y"
1.196 moko 2968: {
1.131 misha 2969: // optimized OP_STRING+OP_WRITE_VALUE => OP_STRING__WRITE
1.181 moko 2970: change_string_literal_to_write_string_literal(*(yyval=yyvsp[0]));
1.158 misha 2971: }
1.197 ! moko 2972: #line 2973 "compile.tab.C"
1.112 paf 2973: break;
2974:
1.196 moko 2975: case 173: /* empty_value: %empty */
1.197 ! moko 2976: #line 824 "compile.y"
1.196 moko 2977: { yyval=VL(/*we know that we will not change it*/const_cast<VString*>(&vempty), 0, 0, 0); }
1.197 ! moko 2978: #line 2979 "compile.tab.C"
1.112 paf 2979: break;
2980:
1.196 moko 2981: case 174: /* true_value: "true" */
1.197 ! moko 2982: #line 825 "compile.y"
1.196 moko 2983: { yyval = VL(/*we know that we will not change it*/const_cast<VBool*>(&vtrue), 0, 0, 0); }
1.197 ! moko 2984: #line 2985 "compile.tab.C"
1.112 paf 2985: break;
2986:
1.196 moko 2987: case 175: /* false_value: "false" */
1.197 ! moko 2988: #line 826 "compile.y"
1.196 moko 2989: { yyval = VL(/*we know that we will not change it*/const_cast<VBool*>(&vfalse), 0, 0, 0); }
1.197 ! moko 2990: #line 2991 "compile.tab.C"
1.112 paf 2991: break;
2992:
1.196 moko 2993: case 176: /* empty: %empty */
1.197 ! moko 2994: #line 828 "compile.y"
1.196 moko 2995: { yyval=N(); }
1.197 ! moko 2996: #line 2997 "compile.tab.C"
1.155 misha 2997: break;
1.154 moko 2998:
1.112 paf 2999:
1.197 ! moko 3000: #line 3001 "compile.tab.C"
1.196 moko 3001:
1.156 moko 3002: default: break;
1.155 misha 3003: }
1.158 misha 3004: /* User semantic actions sometimes alter yychar, and that requires
3005: that yytoken be updated with the new translation. We take the
3006: approach of translating immediately before every use of yytoken.
3007: One alternative is translating here after every semantic action,
3008: but that translation would be missed if the semantic action invokes
3009: YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
3010: if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
3011: incorrect destructor might then be invoked immediately. In the
3012: case of YYERROR or YYBACKUP, subsequent parser actions might lead
3013: to an incorrect destructor call or verbose syntax error message
3014: before the lookahead is translated. */
1.196 moko 3015: YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1.112 paf 3016:
1.156 moko 3017: YYPOPSTACK (yylen);
3018: yylen = 0;
1.1 parser 3019:
3020: *++yyvsp = yyval;
3021:
1.163 moko 3022: /* Now 'shift' the result of the reduction. Determine what state
1.112 paf 3023: that goes to, based on the state we popped back to and the rule
3024: number reduced by. */
1.181 moko 3025: {
3026: const int yylhs = yyr1[yyn] - YYNTOKENS;
3027: const int yyi = yypgoto[yylhs] + *yyssp;
3028: yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
3029: ? yytable[yyi]
3030: : yydefgoto[yylhs]);
3031: }
1.1 parser 3032:
3033: goto yynewstate;
3034:
3035:
1.163 moko 3036: /*--------------------------------------.
3037: | yyerrlab -- here on detecting error. |
3038: `--------------------------------------*/
1.112 paf 3039: yyerrlab:
1.158 misha 3040: /* Make sure we have latest lookahead translation. See comments at
3041: user semantic actions for why this is necessary. */
1.196 moko 3042: yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1.112 paf 3043: /* If not already recovering from an error, report this error. */
3044: if (!yyerrstatus)
1.1 parser 3045: {
3046: ++yynerrs;
1.156 moko 3047: {
1.196 moko 3048: yypcontext_t yyctx
3049: = {yyssp, yytoken};
1.158 misha 3050: char const *yymsgp = YY_("syntax error");
3051: int yysyntax_error_status;
1.196 moko 3052: yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
1.158 misha 3053: if (yysyntax_error_status == 0)
3054: yymsgp = yymsg;
1.196 moko 3055: else if (yysyntax_error_status == -1)
1.158 misha 3056: {
3057: if (yymsg != yymsgbuf)
3058: YYSTACK_FREE (yymsg);
1.196 moko 3059: yymsg = YY_CAST (char *,
3060: YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
3061: if (yymsg)
1.158 misha 3062: {
1.196 moko 3063: yysyntax_error_status
3064: = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
3065: yymsgp = yymsg;
1.158 misha 3066: }
3067: else
3068: {
1.196 moko 3069: yymsg = yymsgbuf;
3070: yymsg_alloc = sizeof yymsgbuf;
3071: yysyntax_error_status = YYENOMEM;
1.158 misha 3072: }
3073: }
1.163 moko 3074: yyerror (pc, yymsgp);
1.196 moko 3075: if (yysyntax_error_status == YYENOMEM)
3076: YYNOMEM;
1.156 moko 3077: }
1.1 parser 3078: }
3079:
3080: if (yyerrstatus == 3)
3081: {
1.112 paf 3082: /* If just tried and failed to reuse lookahead token after an
1.163 moko 3083: error, discard it. */
1.109 paf 3084:
1.113 paf 3085: if (yychar <= YYEOF)
1.163 moko 3086: {
3087: /* Return failure if at end of input. */
3088: if (yychar == YYEOF)
3089: YYABORT;
3090: }
1.113 paf 3091: else
1.163 moko 3092: {
3093: yydestruct ("Error: discarding",
3094: yytoken, &yylval, pc);
3095: yychar = YYEMPTY;
3096: }
1.106 paf 3097: }
1.1 parser 3098:
1.112 paf 3099: /* Else will try to reuse lookahead token after shifting the error
3100: token. */
3101: goto yyerrlab1;
1.109 paf 3102:
1.1 parser 3103:
1.113 paf 3104: /*---------------------------------------------------.
3105: | yyerrorlab -- error raised explicitly by YYERROR. |
3106: `---------------------------------------------------*/
3107: yyerrorlab:
1.181 moko 3108: /* Pacify compilers when the user code never invokes YYERROR and the
3109: label yyerrorlab therefore never appears in user code. */
3110: if (0)
3111: YYERROR;
1.196 moko 3112: ++yynerrs;
1.113 paf 3113:
1.163 moko 3114: /* Do not reclaim the symbols of the rule whose action triggered
1.156 moko 3115: this YYERROR. */
3116: YYPOPSTACK (yylen);
3117: yylen = 0;
3118: YY_STACK_PRINT (yyss, yyssp);
1.113 paf 3119: yystate = *yyssp;
3120: goto yyerrlab1;
3121:
3122:
3123: /*-------------------------------------------------------------.
3124: | yyerrlab1 -- common code for both syntax error and YYERROR. |
3125: `-------------------------------------------------------------*/
1.112 paf 3126: yyerrlab1:
1.163 moko 3127: yyerrstatus = 3; /* Each real token shifted decrements this. */
1.1 parser 3128:
1.196 moko 3129: /* Pop stack until we find a state that shifts the error token. */
1.112 paf 3130: for (;;)
1.109 paf 3131: {
1.112 paf 3132: yyn = yypact[yystate];
1.158 misha 3133: if (!yypact_value_is_default (yyn))
1.163 moko 3134: {
1.196 moko 3135: yyn += YYSYMBOL_YYerror;
3136: if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1.163 moko 3137: {
3138: yyn = yytable[yyn];
3139: if (0 < yyn)
3140: break;
3141: }
3142: }
1.1 parser 3143:
1.112 paf 3144: /* Pop the current state because it cannot handle the error token. */
3145: if (yyssp == yyss)
1.163 moko 3146: YYABORT;
1.1 parser 3147:
1.156 moko 3148:
3149: yydestruct ("Error: popping",
1.196 moko 3150: YY_ACCESSING_SYMBOL (yystate), yyvsp, pc);
1.156 moko 3151: YYPOPSTACK (1);
1.113 paf 3152: yystate = *yyssp;
1.112 paf 3153: YY_STACK_PRINT (yyss, yyssp);
1.1 parser 3154: }
3155:
1.163 moko 3156: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1.156 moko 3157: *++yyvsp = yylval;
1.163 moko 3158: YY_IGNORE_MAYBE_UNINITIALIZED_END
1.155 misha 3159:
1.1 parser 3160:
1.156 moko 3161: /* Shift the error token. */
1.196 moko 3162: YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1.112 paf 3163:
1.1 parser 3164: yystate = yyn;
3165: goto yynewstate;
3166:
3167:
1.112 paf 3168: /*-------------------------------------.
3169: | yyacceptlab -- YYACCEPT comes here. |
3170: `-------------------------------------*/
3171: yyacceptlab:
3172: yyresult = 0;
1.196 moko 3173: goto yyreturnlab;
1.112 paf 3174:
1.181 moko 3175:
1.112 paf 3176: /*-----------------------------------.
3177: | yyabortlab -- YYABORT comes here. |
3178: `-----------------------------------*/
3179: yyabortlab:
3180: yyresult = 1;
1.196 moko 3181: goto yyreturnlab;
1.112 paf 3182:
1.181 moko 3183:
1.196 moko 3184: /*-----------------------------------------------------------.
3185: | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
3186: `-----------------------------------------------------------*/
1.156 moko 3187: yyexhaustedlab:
1.163 moko 3188: yyerror (pc, YY_("memory exhausted"));
1.112 paf 3189: yyresult = 2;
1.196 moko 3190: goto yyreturnlab;
1.112 paf 3191:
1.181 moko 3192:
1.196 moko 3193: /*----------------------------------------------------------.
3194: | yyreturnlab -- parsing is finished, clean up and return. |
3195: `----------------------------------------------------------*/
3196: yyreturnlab:
1.156 moko 3197: if (yychar != YYEMPTY)
1.158 misha 3198: {
3199: /* Make sure we have latest lookahead translation. See comments at
3200: user semantic actions for why this is necessary. */
3201: yytoken = YYTRANSLATE (yychar);
3202: yydestruct ("Cleanup: discarding lookahead",
1.163 moko 3203: yytoken, &yylval, pc);
1.158 misha 3204: }
1.163 moko 3205: /* Do not reclaim the symbols of the rule whose action triggered
1.156 moko 3206: this YYABORT or YYACCEPT. */
3207: YYPOPSTACK (yylen);
3208: YY_STACK_PRINT (yyss, yyssp);
3209: while (yyssp != yyss)
3210: {
3211: yydestruct ("Cleanup: popping",
1.196 moko 3212: YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, pc);
1.156 moko 3213: YYPOPSTACK (1);
3214: }
1.112 paf 3215: #ifndef yyoverflow
3216: if (yyss != yyssa)
3217: YYSTACK_FREE (yyss);
1.1 parser 3218: #endif
1.156 moko 3219: if (yymsg != yymsgbuf)
3220: YYSTACK_FREE (yymsg);
1.163 moko 3221: return yyresult;
1.1 parser 3222: }
1.196 moko 3223:
1.197 ! moko 3224: #line 830 "compile.y"
1.1 parser 3225:
3226: #endif
3227:
3228: /*
3229: 000$111(2222)00
3230: 000$111{3333}00
3231: $,^: push,=0
3232: 1:( { break=pop
3233: 2:( ) pop
3234: 3:{ } pop
3235:
3236: 000^111(2222)4444{33333}4000
3237: $,^: push,=0
3238: 1:( { break=pop
3239: 2:( )=4
3240: 3:{ }=4
3241: 4:[^({]=pop
3242: */
3243:
1.84 paf 3244: inline void ungetc(Parse_control& pc, uint last_line_end_col) {
3245: pc.source--;
3246: if(pc.pos.col==0) {
3247: --pc.pos.line; pc.pos.col=last_line_end_col;
3248: } else
3249: --pc.pos.col;
3250:
3251: }
3252: static int yylex(YYSTYPE *lvalp, void *apc) {
1.184 moko 3253: Parse_control& pc=*static_cast<Parse_control*>(apc);
1.84 paf 3254:
3255: #define lexical_brackets_nestage pc.brackets_nestages[pc.ls_sp]
1.1 parser 3256: #define RC {result=c; goto break2; }
3257:
1.184 moko 3258: int c;
1.84 paf 3259: int result;
1.1 parser 3260:
1.84 paf 3261: if(pc.pending_state) {
3262: result=pc.pending_state;
3263: pc.pending_state=0;
1.1 parser 3264: return result;
3265: }
3266:
1.84 paf 3267: const char *begin=pc.source;
3268: Pos begin_pos=pc.pos;
1.1 parser 3269: const char *end;
3270: int skip_analized=0;
3271: while(true) {
1.84 paf 3272: c=*(end=(pc.source++));
3273: // fprintf(stderr, "\nchar: %c %02X; nestage: %d, sp=%d", c, c, lexical_brackets_nestage, pc.sp);
1.1 parser 3274:
1.96 paf 3275: if(c=='\n')
1.84 paf 3276: pc.pos_next_line();
1.96 paf 3277: else
1.84 paf 3278: pc.pos_next_c(c);
1.96 paf 3279: // fprintf(stderr, "\nchar: %c file(%d:%d)", c, pc.pos.line, pc.pos.col);
1.1 parser 3280:
1.96 paf 3281: if(pc.pos.col==0+1 && c=='@') {
1.84 paf 3282: if(pc.ls==LS_DEF_SPECIAL_BODY) {
1.31 paf 3283: // @SPECIAL
3284: // ...
3285: // @<here =
1.84 paf 3286: pop_LS(pc); // exiting from LS_DEF_SPECIAL_BODY state
1.31 paf 3287: } // continuing checks
1.84 paf 3288: if(pc.ls==LS_USER) {
3289: push_LS(pc, LS_DEF_NAME);
1.20 parser 3290: RC;
1.31 paf 3291: } else // @ in first column inside some code [when could that be?]
1.20 parser 3292: result=BAD_METHOD_DECL_START;
3293: goto break2;
1.97 paf 3294: }
3295: if(c=='^') {
1.84 paf 3296: if(pc.ls==LS_METHOD_AFTER) {
1.75 paf 3297: // handle after-method situation
1.84 paf 3298: pop_LS(pc);
1.75 paf 3299: result=EON;
3300: skip_analized=-1; // return to punctuation afterwards to assure it's literality
3301: goto break2;
3302: }
1.84 paf 3303: switch(pc.ls) {
1.15 parser 3304: case LS_EXPRESSION_VAR_NAME_WITH_COLON:
3305: case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON:
3306: case LS_VAR_NAME_SIMPLE_WITH_COLON:
3307: case LS_VAR_NAME_SIMPLE_WITHOUT_COLON:
3308: case LS_VAR_NAME_CURLY:
3309: case LS_METHOD_NAME:
1.66 paf 3310: case LS_USER_COMMENT:
1.15 parser 3311: case LS_DEF_COMMENT:
3312: // no literals in names, please
3313: break;
3314: default:
1.84 paf 3315: switch(*pc.source) {
1.10 parser 3316: // ^escaping some punctuators
1.121 misha 3317: case '^': case '$': case ';': case '@':
1.1 parser 3318: case '(': case ')':
3319: case '[': case ']':
3320: case '{': case '}':
1.23 parser 3321: case '"': case ':':
1.1 parser 3322: if(end!=begin) {
1.84 paf 3323: if(!pc.string_start)
3324: pc.string_start=begin_pos;
1.1 parser 3325: // append piece till ^
1.84 paf 3326: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 3327: }
3328: // reset piece 'begin' position & line
1.84 paf 3329: begin=pc.source; // ->punctuation
3330: begin_pos=pc.pos;
1.75 paf 3331: // skip over _ after ^
1.84 paf 3332: pc.source++; pc.pos.col++;
1.75 paf 3333: // skip analysis = forced literal
3334: continue;
1.1 parser 3335:
3336: // converting ^#HH into char(hex(HH))
3337: case '#':
3338: if(end!=begin) {
1.84 paf 3339: if(!pc.string_start)
3340: pc.string_start=begin_pos;
1.1 parser 3341: // append piece till ^
1.84 paf 3342: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 3343: }
3344: // #HH ?
1.121 misha 3345: if(pc.source[1] && isxdigit(pc.source[1]) && pc.source[2] && isxdigit(pc.source[2])) {
1.110 paf 3346: char c=(char)(
1.84 paf 3347: hex_value[(unsigned char)pc.source[1]]*0x10+
1.110 paf 3348: hex_value[(unsigned char)pc.source[2]]);
1.84 paf 3349: if(c==0) {
1.1 parser 3350: result=BAD_HEX_LITERAL;
3351: goto break2; // wrong hex value[no ^#00 chars allowed]: bail out
3352: }
3353: // append char(hex(HH))
1.84 paf 3354: pc.string.append(c);
1.1 parser 3355: // skip over ^#HH
1.84 paf 3356: pc.source+=3;
3357: pc.pos.col+=3;
1.1 parser 3358: // reset piece 'begin' position & line
1.84 paf 3359: begin=pc.source; // ->after ^#HH
3360: begin_pos=pc.pos;
1.75 paf 3361: // skip analysis = forced literal
1.1 parser 3362: continue;
3363: }
1.121 misha 3364: // just escaped char
3365: // reset piece 'begin' position & line
3366: begin=pc.source;
3367: begin_pos=pc.pos;
3368: // skip over _ after ^
3369: pc.source++; pc.pos.col++;
3370: // skip analysis = forced literal
3371: continue;
1.1 parser 3372: }
1.15 parser 3373: break;
1.75 paf 3374: }
1.15 parser 3375: }
1.1 parser 3376: // #comment start skipping
1.84 paf 3377: if(c=='#' && pc.pos.col==1) {
1.1 parser 3378: if(end!=begin) {
1.84 paf 3379: if(!pc.string_start)
3380: pc.string_start=begin_pos;
1.1 parser 3381: // append piece till #
1.84 paf 3382: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 3383: }
3384: // fall into COMMENT lexical state [wait for \n]
1.84 paf 3385: push_LS(pc, LS_USER_COMMENT);
1.31 paf 3386: continue;
1.1 parser 3387: }
1.84 paf 3388: switch(pc.ls) {
1.1 parser 3389:
3390: // USER'S = NOT OURS
3391: case LS_USER:
1.84 paf 3392: case LS_NAME_SQUARE_PART: // name.[here].xxx
3393: if(pc.trim_bof)
1.1 parser 3394: switch(c) {
3395: case '\n': case ' ': case '\t':
1.84 paf 3396: begin=pc.source;
3397: begin_pos=pc.pos;
1.1 parser 3398: continue; // skip it
3399: default:
1.84 paf 3400: pc.trim_bof=false;
1.1 parser 3401: }
3402: switch(c) {
3403: case '$':
1.84 paf 3404: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3405: RC;
3406: case '^':
1.84 paf 3407: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3408: RC;
1.11 parser 3409: case ']':
1.84 paf 3410: if(pc.ls==LS_NAME_SQUARE_PART)
1.11 parser 3411: if(--lexical_brackets_nestage==0) {// $name.[co<]?>de<]?>
1.84 paf 3412: pop_LS(pc); // $name.[co<]>de<]!>
1.11 parser 3413: RC;
3414: }
1.3 parser 3415: break;
1.11 parser 3416: case '[': // $name.[co<[>de]
1.84 paf 3417: if(pc.ls==LS_NAME_SQUARE_PART)
1.11 parser 3418: lexical_brackets_nestage++;
1.4 parser 3419: break;
1.1 parser 3420: }
1.97 paf 3421: if(pc.explicit_result && c)
3422: switch(c) {
1.168 moko 3423: default:
3424: pc.string.append(c);
1.97 paf 3425: case '\n': case ' ': case '\t':
3426: begin=pc.source;
3427: begin_pos=pc.pos;
1.168 moko 3428: continue;
1.97 paf 3429: }
1.1 parser 3430: break;
3431:
3432: // #COMMENT
1.66 paf 3433: case LS_USER_COMMENT:
1.1 parser 3434: if(c=='\n') {
3435: // skip comment
1.84 paf 3436: begin=pc.source;
3437: begin_pos=pc.pos;
1.1 parser 3438:
1.84 paf 3439: pop_LS(pc);
1.1 parser 3440: continue;
3441: }
3442: break;
3443:
3444: // STRING IN EXPRESSION
3445: case LS_EXPRESSION_STRING_QUOTED:
3446: case LS_EXPRESSION_STRING_APOSTROFED:
3447: switch(c) {
3448: case '"':
3449: case '\'':
3450: if(
1.162 moko 3451: (pc.ls == LS_EXPRESSION_STRING_QUOTED && c=='"') ||
3452: (pc.ls == LS_EXPRESSION_STRING_APOSTROFED && c=='\'') ) {
1.84 paf 3453: pop_LS(pc); //"abc". | 'abc'.
1.1 parser 3454: RC;
3455: }
3456: break;
3457: case '$':
1.84 paf 3458: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3459: RC;
3460: case '^':
1.84 paf 3461: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3462: RC;
3463: }
3464: break;
3465:
3466: // METHOD DEFINITION
3467: case LS_DEF_NAME:
3468: switch(c) {
3469: case '[':
1.84 paf 3470: pc.ls=LS_DEF_PARAMS;
1.1 parser 3471: RC;
3472: case '\n':
1.84 paf 3473: pc.ls=LS_DEF_SPECIAL_BODY;
1.1 parser 3474: RC;
3475: }
3476: break;
3477:
3478: case LS_DEF_PARAMS:
3479: switch(c) {
1.64 paf 3480: case '$': // common error
1.65 paf 3481: result=BAD_METHOD_PARAMETER_NAME_CHARACTER;
3482: goto break2;
1.1 parser 3483: case ';':
3484: RC;
3485: case ']':
1.84 paf 3486: pc.ls=*pc.source=='['?LS_DEF_LOCALS:LS_DEF_COMMENT;
1.1 parser 3487: RC;
3488: case '\n': // wrong. bailing out
1.84 paf 3489: pop_LS(pc);
1.1 parser 3490: RC;
3491: }
3492: break;
3493:
3494: case LS_DEF_LOCALS:
3495: switch(c) {
3496: case '[':
3497: case ';':
3498: RC;
3499: case ']':
1.84 paf 3500: pc.ls=LS_DEF_COMMENT;
1.1 parser 3501: RC;
3502: case '\n': // wrong. bailing out
1.84 paf 3503: pop_LS(pc);
1.1 parser 3504: RC;
3505: }
3506: break;
3507:
3508: case LS_DEF_COMMENT:
3509: if(c=='\n') {
1.84 paf 3510: pop_LS(pc);
1.1 parser 3511: RC;
3512: }
3513: break;
3514:
3515: case LS_DEF_SPECIAL_BODY:
1.31 paf 3516: if(c=='\n')
1.1 parser 3517: RC;
3518: break;
3519:
3520: // (EXPRESSION)
3521: case LS_VAR_ROUND:
3522: case LS_METHOD_ROUND:
3523: switch(c) {
3524: case ')':
1.162 moko 3525: if(--lexical_brackets_nestage==0) {
1.84 paf 3526: if(pc.ls==LS_METHOD_ROUND) // method round param ended
3527: pc.ls=LS_METHOD_AFTER; // look for method end
3528: else // pc.ls==LS_VAR_ROUND // variable constructor ended
3529: pop_LS(pc); // return to normal life
1.162 moko 3530: }
1.1 parser 3531: RC;
1.66 paf 3532: case '#': // comment start skipping
3533: if(end!=begin) {
1.84 paf 3534: if(!pc.string_start)
3535: pc.string_start=begin_pos;
1.66 paf 3536: // append piece till #
1.84 paf 3537: pc.string.append_strdup_know_length(begin, end-begin);
1.66 paf 3538: }
3539: // fall into COMMENT lexical state [wait for \n]
1.84 paf 3540: push_LS(pc, LS_EXPRESSION_COMMENT);
1.66 paf 3541: lexical_brackets_nestage=1;
3542: continue;
1.1 parser 3543: case '$':
1.84 paf 3544: push_LS(pc, LS_EXPRESSION_VAR_NAME_WITH_COLON);
1.1 parser 3545: RC;
3546: case '^':
1.84 paf 3547: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3548: RC;
3549: case '(':
3550: lexical_brackets_nestage++;
3551: RC;
3552: case '-':
1.84 paf 3553: switch(*pc.source) {
1.1 parser 3554: case 'f': // -f
3555: skip_analized=1;
3556: result=FEXISTS;
3557: goto break2;
3558: case 'd': // -d
3559: skip_analized=1;
3560: result=DEXISTS;
3561: goto break2;
1.63 paf 3562: default: // minus
1.1 parser 3563: result=c;
3564: goto break2;
3565: }
3566: goto break2;
1.25 paf 3567: case '+': case '*': case '/': case '%': case '\\':
1.1 parser 3568: case '~':
3569: case ';':
3570: RC;
1.65 paf 3571: case '&': case '|':
1.84 paf 3572: if(*pc.source==c) { // && ||
1.65 paf 3573: result=c=='&'?LAND:LOR;
1.1 parser 3574: skip_analized=1;
3575: } else
3576: result=c;
3577: goto break2;
1.65 paf 3578: case '!':
1.84 paf 3579: switch(pc.source[0]) {
1.65 paf 3580: case '|': // !| !||
3581: skip_analized=1;
1.84 paf 3582: if(pc.source[1]=='|') {
1.65 paf 3583: skip_analized++;
3584: result=LXOR;
3585: } else
3586: result=NXOR;
3587: goto break2;
3588: case '=': // !=
3589: skip_analized=1;
3590: result=NNE;
3591: goto break2;
3592: }
3593: RC;
1.67 paf 3594:
3595: case '<': // <<, <=, <
1.84 paf 3596: switch(*pc.source) {
1.67 paf 3597: case '<': // <[<]
3598: skip_analized=1; result=NSL; break;
3599: case '=': // <[=]
3600: skip_analized=1; result=NLE; break;
3601: default: // <[]
3602: result=c; break;
3603: }
3604: goto break2;
3605: case '>': // >>, >=, >
1.84 paf 3606: switch(*pc.source) {
1.67 paf 3607: case '>': // >[>]
3608: skip_analized=1; result=NSR; break;
3609: case '=': // >[=]
3610: skip_analized=1; result=NGE; break;
3611: default: // >[]
3612: result=c; break;
3613: }
3614: goto break2;
3615: case '=': // ==
1.84 paf 3616: switch(*pc.source) {
1.67 paf 3617: case '=': // =[=]
3618: skip_analized=1; result=NEQ; break;
3619: default: // =[]
3620: result=c; break; // not used now
3621: }
1.1 parser 3622: goto break2;
1.67 paf 3623:
1.1 parser 3624: case '"':
1.84 paf 3625: push_LS(pc, LS_EXPRESSION_STRING_QUOTED);
1.1 parser 3626: RC;
3627: case '\'':
1.84 paf 3628: push_LS(pc, LS_EXPRESSION_STRING_APOSTROFED);
1.1 parser 3629: RC;
3630: case 'l': case 'g': case 'e': case 'n':
3631: if(end==begin) // right after whitespace
1.84 paf 3632: if(isspace(pc.source[1])) {
3633: switch(*pc.source) {
1.1 parser 3634: // case '?': // ok [and bad cases, yacc would bark at them]
3635: case 't': // lt gt [et nt]
3636: result=c=='l'?SLT:c=='g'?SGT:BAD_STRING_COMPARISON_OPERATOR;
3637: skip_analized=1;
3638: goto break2;
3639: case 'e': // le ge ne [ee]
3640: result=c=='l'?SLE:c=='g'?SGE:c=='n'?SNE:BAD_STRING_COMPARISON_OPERATOR;
3641: skip_analized=1;
3642: goto break2;
3643: case 'q': // eq [lq gq nq]
3644: result=c=='e'?SEQ:BAD_STRING_COMPARISON_OPERATOR;
3645: skip_analized=1;
3646: goto break2;
3647: }
3648: }
3649: break;
3650: case 'i':
3651: if(end==begin) // right after whitespace
1.84 paf 3652: if(isspace(pc.source[1])) {
3653: switch(pc.source[0]) {
1.1 parser 3654: case 'n': // in
3655: skip_analized=1;
3656: result=IN;
3657: goto break2;
3658: case 's': // is
3659: skip_analized=1;
3660: result=IS;
3661: goto break2;
3662: }
3663: }
3664: break;
3665: case 'd':
3666: if(end==begin) // right after whitespace
1.84 paf 3667: if(pc.source[0]=='e' && pc.source[1]=='f') { // def
1.118 misha 3668: switch(pc.source[2]){
3669: case ' ': case '\t': case '\n': case '"': case '\'': case '^': case '$': // non-quoted string without whitespace after 'def' is not allowed
3670: skip_analized=2;
3671: result=DEF;
3672: goto break2;
3673: }
3674: // error: incorrect char after 'def'
1.1 parser 3675: }
3676: break;
1.107 paf 3677: case 't':
3678: if(end==begin) // right after whitespace
1.118 misha 3679: if(pc.source[0]=='r' && pc.source[1]=='u' && pc.source[2]=='e') { // true
1.107 paf 3680: skip_analized=3;
3681: result=LITERAL_TRUE;
3682: goto break2;
3683: }
3684: break;
3685: case 'f':
3686: if(end==begin) // right after whitespace
1.118 misha 3687: if(pc.source[0]=='a' && pc.source[1]=='l' && pc.source[2]=='s' && pc.source[3]=='e') { // false
1.107 paf 3688: skip_analized=4;
3689: result=LITERAL_FALSE;
3690: goto break2;
3691: }
3692: break;
1.1 parser 3693: case ' ': case '\t': case '\n':
3694: if(end!=begin) { // there were a string after previous operator?
3695: result=0; // return that string
3696: goto break2;
3697: }
3698: // that's a leading|traling space or after-operator-space
3699: // ignoring it
3700: // reset piece 'begin' position & line
1.84 paf 3701: begin=pc.source; // after whitespace char
3702: begin_pos=pc.pos;
1.1 parser 3703: continue;
3704: }
3705: break;
1.66 paf 3706: case LS_EXPRESSION_COMMENT:
3707: if(c=='(')
3708: lexical_brackets_nestage++;
3709:
1.84 paf 3710: switch(*pc.source) {
1.66 paf 3711: case '\n': case ')':
1.84 paf 3712: if(*pc.source==')')
1.66 paf 3713: if(--lexical_brackets_nestage!=0)
3714: continue;
3715:
3716: // skip comment
1.84 paf 3717: begin=pc.source;
3718: begin_pos=pc.pos;
1.66 paf 3719:
1.84 paf 3720: pop_LS(pc);
1.66 paf 3721: continue;
3722: }
3723: break;
1.1 parser 3724:
3725: // VARIABLE GET/PUT/WITH
1.11 parser 3726: case LS_VAR_NAME_SIMPLE_WITH_COLON:
3727: case LS_VAR_NAME_SIMPLE_WITHOUT_COLON:
3728: case LS_EXPRESSION_VAR_NAME_WITH_COLON:
3729: case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON:
3730: if(
1.84 paf 3731: pc.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON ||
3732: pc.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) {
1.41 paf 3733: // name in expr ends also before
1.1 parser 3734: switch(c) {
1.41 paf 3735: // expression minus
1.1 parser 3736: case '-':
1.41 paf 3737: // expression integer division
3738: case '\\':
1.84 paf 3739: pop_LS(pc);
3740: pc.ungetc();
1.1 parser 3741: result=EON;
3742: goto break2;
3743: }
3744: }
1.11 parser 3745: if(
1.84 paf 3746: pc.ls==LS_VAR_NAME_SIMPLE_WITHOUT_COLON ||
3747: pc.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) {
1.1 parser 3748: // name already has ':', stop before next
3749: switch(c) {
3750: case ':':
1.84 paf 3751: pop_LS(pc);
3752: pc.ungetc();
1.1 parser 3753: result=EON;
3754: goto break2;
3755: }
3756: }
3757: switch(c) {
3758: case 0:
3759: case ' ': case '\t': case '\n':
3760: case ';':
3761: case ']': case '}': case ')':
3762: case '"': case '\'':
3763: case '<': case '>': // these stand for HTML brackets AND expression binary ops
1.146 misha 3764: case '+': case '*': case '/': case '\\': case '%':
1.1 parser 3765: case '&': case '|':
3766: case '=': case '!':
3767: // common delimiters
1.62 paf 3768: case ',': case '?': case '#':
1.113 paf 3769: // mysql column separators
3770: case '`':
1.1 parser 3771: // before call
3772: case '^':
1.84 paf 3773: pop_LS(pc);
3774: pc.ungetc();
1.1 parser 3775: result=EON;
3776: goto break2;
3777: case '[':
1.5 parser 3778: // $name.<[>code]
1.190 moko 3779: if( end[-1]=='$' /* was start of get */ ||
3780: end[-1]==':' /* was class name delim */ ||
3781: end[-1]=='.' /* was name delim */
1.189 moko 3782: ) {
1.84 paf 3783: push_LS(pc, LS_NAME_SQUARE_PART);
1.5 parser 3784: lexical_brackets_nestage=1;
3785: RC;
3786: }
1.84 paf 3787: pc.ls=LS_VAR_SQUARE;
1.1 parser 3788: lexical_brackets_nestage=1;
3789: RC;
3790: case '{':
1.189 moko 3791: if(end[-1]=='$') { // ${name}, no need of EON, switching LS, not begin==end as $[a]{$b} will fit
1.84 paf 3792: pc.ls=LS_VAR_NAME_CURLY;
1.1 parser 3793: } else {
1.84 paf 3794: pc.ls=LS_VAR_CURLY;
1.1 parser 3795: lexical_brackets_nestage=1;
3796: }
3797:
3798: RC;
3799: case '(':
1.190 moko 3800: // $name.<(>expr)
3801: if( // end[-1]=='$' /* $() excluded */ ||
3802: end[-1]==':' /* was class name delim */ ||
3803: end[-1]=='.' /* was name delim */
3804: ) {
3805: push_LS(pc, LS_VAR_ROUND);
3806: lexical_brackets_nestage=1;
3807: RC;
3808: }
1.84 paf 3809: pc.ls=LS_VAR_ROUND;
1.1 parser 3810: lexical_brackets_nestage=1;
3811: RC;
3812: case '.': // name part delim
3813: case '$': // name part subvar
1.3 parser 3814: case ':': // class<:>name
1.11 parser 3815: // go to _WITHOUT_COLON state variant...
1.84 paf 3816: if(pc.ls==LS_VAR_NAME_SIMPLE_WITH_COLON)
3817: pc.ls=LS_VAR_NAME_SIMPLE_WITHOUT_COLON;
3818: else if(pc.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON)
3819: pc.ls=LS_EXPRESSION_VAR_NAME_WITHOUT_COLON;
1.11 parser 3820: // ...stop before next ':'
1.1 parser 3821: RC;
3822: }
3823: break;
3824:
3825: case LS_VAR_NAME_CURLY:
3826: switch(c) {
1.5 parser 3827: case '[':
1.11 parser 3828: // ${name.<[>code]}
1.84 paf 3829: push_LS(pc, LS_NAME_SQUARE_PART);
1.3 parser 3830: lexical_brackets_nestage=1;
3831: RC;
1.190 moko 3832: case '(':
3833: // ${name.<(>expr)}
3834: push_LS(pc, LS_VAR_ROUND);
3835: lexical_brackets_nestage=1;
3836: RC;
1.1 parser 3837: case '}': // ${name} finished, restoring LS
1.84 paf 3838: pop_LS(pc);
1.1 parser 3839: RC;
3840: case '.': // name part delim
3841: case '$': // name part subvar
3842: case ':': // ':name' or 'class:name'
3843: RC;
3844: }
3845: break;
3846:
3847: case LS_VAR_SQUARE:
3848: switch(c) {
3849: case '$':
1.84 paf 3850: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3851: RC;
3852: case '^':
1.84 paf 3853: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3854: RC;
3855: case ']':
3856: if(--lexical_brackets_nestage==0) {
1.84 paf 3857: pop_LS(pc);
1.1 parser 3858: RC;
3859: }
3860: break;
3861: case ';': // operator_or_fmt;value delim
3862: RC;
3863: case '[':
3864: lexical_brackets_nestage++;
3865: break;
3866: }
3867: break;
3868:
3869: case LS_VAR_CURLY:
3870: switch(c) {
3871: case '$':
1.84 paf 3872: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3873: RC;
3874: case '^':
1.84 paf 3875: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3876: RC;
3877: case '}':
3878: if(--lexical_brackets_nestage==0) {
1.84 paf 3879: pop_LS(pc);
1.1 parser 3880: RC;
3881: }
3882: break;
3883: case '{':
3884: lexical_brackets_nestage++;
3885: break;
3886: }
3887: break;
3888:
3889: // METHOD CALL
3890: case LS_METHOD_NAME:
3891: switch(c) {
3892: case '[':
1.190 moko 3893: // ^name.<[>code]
3894: if( // end[-1]=='^' /* never, ^[ is literal */ ||
3895: end[-1]==':' /* was class name delim */ ||
3896: end[-1]=='.' /* was name delim */
3897: ) {
1.84 paf 3898: push_LS(pc, LS_NAME_SQUARE_PART);
1.5 parser 3899: lexical_brackets_nestage=1;
3900: RC;
3901: }
1.84 paf 3902: pc.ls=LS_METHOD_SQUARE;
1.1 parser 3903: lexical_brackets_nestage=1;
3904: RC;
3905: case '{':
1.84 paf 3906: pc.ls=LS_METHOD_CURLY;
1.1 parser 3907: lexical_brackets_nestage=1;
3908: RC;
3909: case '(':
1.190 moko 3910: // ^name.<(>expr)
3911: if( // end[-1]=='^' /* never, ^( is literal */ ||
3912: end[-1]==':' /* was class name delim */ ||
3913: end[-1]=='.' /* was name delim */
3914: ) {
3915: push_LS(pc, LS_VAR_ROUND);
3916: lexical_brackets_nestage=1;
3917: RC;
3918: }
1.84 paf 3919: pc.ls=LS_METHOD_ROUND;
1.1 parser 3920: lexical_brackets_nestage=1;
3921: RC;
3922: case '.': // name part delim
3923: case '$': // name part subvar
3924: case ':': // ':name' or 'class:name'
1.19 parser 3925: case '^': // ^abc^xxx wrong. bailing out
3926: case ']': case '}': case ')': // ^abc]}) wrong. bailing out
1.90 paf 3927: case ' ': // ^if ( wrong. bailing out
1.1 parser 3928: RC;
3929: }
3930: break;
3931:
3932: case LS_METHOD_SQUARE:
3933: switch(c) {
3934: case '$':
1.84 paf 3935: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3936: RC;
3937: case '^':
1.84 paf 3938: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3939: RC;
3940: case ';': // param delim
3941: RC;
3942: case ']':
3943: if(--lexical_brackets_nestage==0) {
1.84 paf 3944: pc.ls=LS_METHOD_AFTER;
1.1 parser 3945: RC;
3946: }
3947: break;
3948: case '[':
3949: lexical_brackets_nestage++;
3950: break;
3951: }
3952: break;
3953:
3954: case LS_METHOD_CURLY:
3955: switch(c) {
3956: case '$':
1.84 paf 3957: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 3958: RC;
3959: case '^':
1.84 paf 3960: push_LS(pc, LS_METHOD_NAME);
1.1 parser 3961: RC;
3962: case ';': // param delim
3963: RC;
3964: case '}':
3965: if(--lexical_brackets_nestage==0) {
1.84 paf 3966: pc.ls=LS_METHOD_AFTER;
1.1 parser 3967: RC;
3968: }
3969: break;
3970: case '{':
3971: lexical_brackets_nestage++;
3972: break;
3973: }
1.97 paf 3974: if(pc.explicit_result && c)
3975: switch(c) {
1.168 moko 3976: default:
3977: pc.string.append(c);
1.97 paf 3978: case '\n': case ' ': case '\t':
3979: begin=pc.source;
3980: begin_pos=pc.pos;
1.168 moko 3981: continue;
1.97 paf 3982: }
1.1 parser 3983: break;
3984:
3985: case LS_METHOD_AFTER:
3986: if(c=='[') {/* ][ }[ )[ */
1.84 paf 3987: pc.ls=LS_METHOD_SQUARE;
1.1 parser 3988: lexical_brackets_nestage=1;
3989: RC;
1.171 moko 3990: }
1.1 parser 3991: if(c=='{') {/* ]{ }{ ){ */
1.84 paf 3992: pc.ls=LS_METHOD_CURLY;
1.1 parser 3993: lexical_brackets_nestage=1;
3994: RC;
1.171 moko 3995: }
1.1 parser 3996: if(c=='(') {/* ]( }( )( */
1.84 paf 3997: pc.ls=LS_METHOD_ROUND;
1.1 parser 3998: lexical_brackets_nestage=1;
3999: RC;
1.171 moko 4000: }
1.84 paf 4001: pop_LS(pc);
4002: pc.ungetc();
1.1 parser 4003: result=EON;
4004: goto break2;
4005: }
4006: if(c==0) {
4007: result=-1;
4008: break;
4009: }
4010: }
4011:
4012: break2:
4013: if(end!=begin) { // there is last piece?
1.150 misha 4014: if(c=='@' || c==0) // we are before LS_DEF_NAME or EOF?
4015: while(end!=begin && end[-1]=='\n') // trim all empty lines before LS_DEF_NAME and EOF
1.1 parser 4016: end--;
1.84 paf 4017: if(end!=begin && pc.ls!=LS_USER_COMMENT) { // last piece still alive and not comment?
4018: if(!pc.string_start)
4019: pc.string_start=begin_pos;
1.1 parser 4020: // append it
1.84 paf 4021: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 4022: }
4023: }
1.84 paf 4024: if(!pc.string.is_empty()) { // something accumulated?
4025: // create STRING value: array of OP_VALUE+origin+vstring
1.170 moko 4026: #ifdef SYMBOLS_CACHING
4027: Value *lookup=symbols->get(pc.string);
4028: #else
4029: Value *lookup=0;
4030: #endif
1.171 moko 4031: *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 4032: // new pieces storage
1.84 paf 4033: pc.string.clear();
4034: pc.string_start.clear();
1.1 parser 4035: // make current result be pending for next call, return STRING for now
1.84 paf 4036: pc.pending_state=result; result=STRING;
1.1 parser 4037: }
4038: if(skip_analized) {
1.84 paf 4039: pc.source+=skip_analized; pc.pos.col+=skip_analized;
1.1 parser 4040: }
4041: return result;
4042: }
4043:
1.156 moko 4044: static int real_yyerror(Parse_control *pc, const char *s) { // Called by yyparse on error
1.182 moko 4045: PC.error=pa_strdup(s);
1.171 moko 4046: return 1;
1.1 parser 4047: }
4048:
4049: static void yyprint(FILE *file, int type, YYSTYPE value) {
4050: if(type==STRING)
1.84 paf 4051: fprintf(file, " \"%s\"", LA2S(*value)->cstr());
1.1 parser 4052: }
E-mail: