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