Annotation of parser3/src/main/compile.tab.C, revision 1.85.2.1
1.1 parser 1:
2: /* A Bison parser, made from compile.y
3: by GNU Bison version 1.28 */
4:
5: #define YYBISON 1 /* Identify Bison output. */
6:
7: #define EON 257
8: #define STRING 258
9: #define BOGUS 259
10: #define BAD_STRING_COMPARISON_OPERATOR 260
11: #define BAD_HEX_LITERAL 261
1.20 parser 12: #define BAD_METHOD_DECL_START 262
1.65 paf 13: #define BAD_METHOD_PARAMETER_NAME_CHARACTER 263
14: #define BAD_MATH_OPERATOR_CHARACTER 264
15: #define LAND 265
16: #define LOR 266
17: #define LXOR 267
18: #define NXOR 268
19: #define NLE 269
20: #define NGE 270
21: #define NEQ 271
22: #define NNE 272
1.67 paf 23: #define NSL 273
24: #define NSR 274
25: #define SLT 275
26: #define SGT 276
27: #define SLE 277
28: #define SGE 278
29: #define SEQ 279
30: #define SNE 280
31: #define DEF 281
32: #define IN 282
33: #define FEXISTS 283
34: #define DEXISTS 284
35: #define IS 285
1.74 paf 36: #define NUNARY 286
1.1 parser 37:
1.14 parser 38: #line 1 "compile.y"
1.1 parser 39:
1.14 parser 40: /** @file
41: Parser: compiler(lexical parser and grammar).
42:
1.80 paf 43: Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com)
1.27 paf 44: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.14 parser 45:
1.85 paf 46: $Id: compile.y,v 1.206 2003/07/24 11:31:23 paf Exp $
1.14 parser 47: */
1.1 parser 48:
49: /**
50: @todo parser4:
51: - cache compiled code from request to request. to do that...
52: -#: make method definitions, @CLASS, @BASE, @USE instructions,
53: which would be executed afterwards, and actions
54: now performed at compile time would be delayed to run time.
55: -#: make cache expiration on time and on disk-change of class source
56: -#: in apache use subpools for compiled class storage
57: -#: in iis make up specialized Pool object for that
58: */
59:
1.84 paf 60: #define YYSTYPE ArrayOperation*
1.1 parser 61: #define YYPARSE_PARAM pc
62: #define YYLEX_PARAM pc
63: #define YYDEBUG 1
64: #define YYERROR_VERBOSE 1
1.84 paf 65: #define yyerror(msg) real_yyerror((Parse_control *)pc, msg)
1.1 parser 66: #define YYPRINT(file, type, value) yyprint(file, type, value)
67:
1.84 paf 68: // includes
69:
1.1 parser 70: #include "compile_tools.h"
71: #include "pa_value.h"
72: #include "pa_request.h"
73: #include "pa_vobject.h"
74: #include "pa_vdouble.h"
75: #include "pa_globals.h"
76: #include "pa_vvoid.h"
1.72 paf 77: #include "pa_vmethod_frame.h"
1.1 parser 78:
1.84 paf 79: // defines
80:
1.1 parser 81: #define USE_CONTROL_METHOD_NAME "USE"
82:
1.84 paf 83: // forwards
84:
85: static int real_yyerror(Parse_control* pc, char* s);
86: static void yyprint(FILE* file, int type, YYSTYPE value);
87: static int yylex(YYSTYPE* lvalp, void* pc);
1.1 parser 88:
89:
90: // local convinient inplace typecast & var
1.83 paf 91: #undef PC
1.84 paf 92: #define PC (*(Parse_control *)pc)
93: #undef POOL
1.1 parser 94: #define POOL (*PC.pool)
95: #ifndef DOXYGEN
96: #ifndef YYSTYPE
97: #define YYSTYPE int
98: #endif
99: #include <stdio.h>
100:
101: #ifndef __cplusplus
102: #ifndef __STDC__
103: #define const
104: #endif
105: #endif
106:
107:
108:
1.67 paf 109: #define YYFINAL 252
1.1 parser 110: #define YYFLAG -32768
1.67 paf 111: #define YYNTBASE 60
1.1 parser 112:
1.67 paf 113: #define YYTRANSLATE(x) ((unsigned)(x) <= 286 ? yytranslate[x] : 139)
1.1 parser 114:
115: static const char yytranslate[] = { 0,
1.67 paf 116: 2, 2, 2, 2, 2, 2, 2, 2, 2, 46,
1.1 parser 117: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
118: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1.74 paf 119: 2, 2, 44, 58, 2, 50, 41, 35, 59, 54,
120: 55, 38, 36, 2, 37, 53, 39, 2, 2, 2,
1.67 paf 121: 2, 2, 2, 2, 2, 2, 2, 57, 49, 32,
122: 2, 33, 2, 45, 2, 2, 2, 2, 2, 2,
1.1 parser 123: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
124: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1.74 paf 125: 47, 40, 48, 56, 2, 2, 2, 2, 2, 2,
1.1 parser 126: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
127: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1.74 paf 128: 2, 2, 51, 34, 52, 43, 2, 2, 2, 2,
1.1 parser 129: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
130: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
131: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
132: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
133: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
134: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
135: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
136: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
137: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
138: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
139: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
140: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
141: 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
142: 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1.20 parser 143: 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1.74 paf 144: 27, 28, 29, 30, 31, 42
1.1 parser 145: };
146:
147: #if YYDEBUG != 0
148: static const short yyprhs[] = { 0,
149: 0, 2, 4, 6, 9, 11, 13, 15, 20, 22,
150: 24, 26, 29, 32, 34, 36, 44, 46, 48, 52,
151: 54, 56, 58, 62, 64, 66, 68, 70, 72, 75,
152: 77, 79, 81, 83, 85, 87, 90, 93, 95, 99,
153: 101, 103, 105, 108, 110, 113, 117, 119, 121, 123,
154: 125, 128, 131, 133, 135, 137, 141, 145, 149, 151,
155: 153, 155, 157, 159, 161, 164, 166, 167, 168, 175,
156: 177, 179, 182, 184, 186, 188, 192, 196, 200, 202,
157: 206, 208, 212, 214, 218, 220, 222, 224, 226, 228,
158: 230, 232, 234, 237, 239, 242, 245, 247, 249, 252,
1.3 parser 159: 254, 256, 258, 260, 263, 266, 270, 272, 274, 277,
160: 280, 282, 284, 287, 290, 292, 294, 296, 298, 302,
1.11 parser 161: 306, 310, 313, 316, 319, 322, 325, 328, 331, 334,
162: 338, 342, 346, 350, 354, 358, 362, 366, 370, 374,
163: 378, 382, 386, 390, 394, 398, 402, 406, 410, 414,
1.67 paf 164: 418, 422, 426, 430, 434, 438, 442, 444, 446, 447
1.1 parser 165: };
166:
1.67 paf 167: static const short yyrhs[] = { 62,
168: 0, 61, 0, 63, 0, 61, 63, 0, 75, 0,
169: 64, 0, 69, 0, 45, 4, 46, 65, 0, 138,
170: 0, 66, 0, 67, 0, 66, 67, 0, 68, 46,
171: 0, 138, 0, 4, 0, 45, 4, 71, 70, 74,
172: 46, 75, 0, 138, 0, 71, 0, 47, 72, 48,
173: 0, 138, 0, 73, 0, 4, 0, 73, 49, 4,
174: 0, 138, 0, 4, 0, 138, 0, 76, 0, 77,
175: 0, 76, 77, 0, 136, 0, 78, 0, 79, 0,
176: 87, 0, 100, 0, 80, 0, 50, 81, 0, 83,
177: 3, 0, 82, 0, 51, 83, 52, 0, 84, 0,
178: 85, 0, 86, 0, 130, 86, 0, 122, 0, 119,
179: 122, 0, 50, 88, 92, 0, 89, 0, 90, 0,
180: 91, 0, 118, 0, 53, 118, 0, 130, 118, 0,
181: 93, 0, 94, 0, 95, 0, 47, 96, 48, 0,
182: 54, 133, 55, 0, 51, 75, 52, 0, 137, 0,
183: 4, 0, 97, 0, 98, 0, 99, 0, 78, 0,
184: 77, 76, 0, 101, 0, 0, 0, 56, 102, 104,
185: 103, 105, 3, 0, 83, 0, 106, 0, 105, 106,
186: 0, 107, 0, 108, 0, 109, 0, 47, 110, 48,
187: 0, 54, 111, 55, 0, 51, 112, 52, 0, 113,
188: 0, 110, 49, 113, 0, 114, 0, 111, 49, 114,
189: 0, 115, 0, 112, 49, 115, 0, 116, 0, 117,
190: 0, 75, 0, 137, 0, 4, 0, 97, 0, 133,
191: 0, 123, 0, 119, 123, 0, 120, 0, 119, 120,
192: 0, 121, 53, 0, 123, 0, 123, 0, 4, 5,
193: 0, 4, 0, 124, 0, 125, 0, 126, 0, 50,
194: 127, 0, 4, 128, 0, 47, 76, 48, 0, 4,
195: 0, 129, 0, 128, 129, 0, 50, 127, 0, 131,
196: 0, 132, 0, 4, 57, 0, 131, 57, 0, 134,
197: 0, 4, 0, 80, 0, 101, 0, 58, 135, 58,
1.74 paf 198: 0, 59, 135, 59, 0, 54, 134, 55, 0, 37,
199: 134, 0, 36, 134, 0, 43, 134, 0, 44, 134,
1.67 paf 200: 0, 27, 134, 0, 28, 134, 0, 29, 134, 0,
1.74 paf 201: 30, 134, 0, 134, 37, 134, 0, 134, 36, 134,
202: 0, 134, 38, 134, 0, 134, 39, 134, 0, 134,
203: 41, 134, 0, 134, 40, 134, 0, 134, 19, 134,
204: 0, 134, 20, 134, 0, 134, 35, 134, 0, 134,
205: 34, 134, 0, 134, 14, 134, 0, 134, 11, 134,
1.67 paf 206: 0, 134, 12, 134, 0, 134, 13, 134, 0, 134,
207: 32, 134, 0, 134, 33, 134, 0, 134, 15, 134,
208: 0, 134, 16, 134, 0, 134, 17, 134, 0, 134,
209: 18, 134, 0, 134, 21, 134, 0, 134, 22, 134,
210: 0, 134, 23, 134, 0, 134, 24, 134, 0, 134,
211: 25, 134, 0, 134, 26, 134, 0, 134, 31, 134,
212: 0, 75, 0, 4, 0, 0, 0
1.1 parser 213: };
214:
215: #endif
216:
217: #if YYDEBUG != 0
218: static const short yyrline[] = { 0,
1.84 paf 219: 121, 129, 131, 131, 132, 134, 134, 136, 208, 208,
220: 209, 209, 210, 211, 211, 213, 242, 242, 243, 244,
221: 244, 245, 245, 247, 247, 251, 251, 253, 253, 254,
222: 254, 255, 255, 255, 259, 266, 267, 267, 268, 269,
223: 271, 272, 294, 295, 295, 299, 303, 305, 306, 307,
224: 324, 329, 331, 333, 334, 336, 342, 350, 356, 358,
225: 359, 361, 367, 368, 368, 372, 378, 381, 384, 397,
226: 399, 399, 400, 402, 403, 405, 406, 407, 408, 410,
227: 412, 414, 416, 418, 420, 424, 428, 432, 434, 435,
228: 437, 446, 446, 448, 448, 449, 450, 458, 463, 465,
229: 467, 468, 469, 471, 475, 484, 490, 495, 495, 496,
230: 501, 503, 505, 517, 529, 534, 536, 537, 538, 539,
231: 540, 542, 543, 544, 545, 546, 547, 548, 549, 551,
232: 552, 553, 554, 555, 556, 557, 558, 559, 560, 561,
233: 562, 563, 564, 565, 566, 567, 568, 569, 570, 571,
234: 572, 573, 574, 575, 576, 577, 580, 589, 594, 595
1.1 parser 235: };
236: #endif
237:
238:
239: #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
240:
241: static const char * const yytname[] = { "$","error","$undefined.","EON","STRING",
1.20 parser 242: "BOGUS","BAD_STRING_COMPARISON_OPERATOR","BAD_HEX_LITERAL","BAD_METHOD_DECL_START",
1.65 paf 243: "BAD_METHOD_PARAMETER_NAME_CHARACTER","BAD_MATH_OPERATOR_CHARACTER","\"&&\"",
1.67 paf 244: "\"||\"","\"!||\"","\"!|\"","\"<=\"","\">=\"","\"==\"","\"!=\"","\"<<\"","\">>\"",
245: "\"lt\"","\"gt\"","\"le\"","\"ge\"","\"eq\"","\"ne\"","\"def\"","\"in\"","\"-f\"",
1.74 paf 246: "\"-d\"","\"is\"","'<'","'>'","'|'","'&'","'+'","'-'","'*'","'/'","'\\\\'","'%'",
247: "NUNARY","'~'","'!'","'@'","'\\n'","'['","']'","';'","'$'","'{'","'}'","'.'",
1.67 paf 248: "'('","')'","'^'","':'","'\\\"'","'\\''","all","methods","one_big_piece","method",
249: "control_method","maybe_control_strings","control_strings","control_string",
250: "maybe_string","code_method","maybe_bracketed_strings","bracketed_maybe_strings",
251: "maybe_strings","strings","maybe_comment","maybe_codes","codes","code","action",
252: "get","get_value","get_name_value","name_in_curly_rdive","name_without_curly_rdive",
253: "name_without_curly_rdive_read","name_without_curly_rdive_class","name_without_curly_rdive_code",
254: "put","name_expr_wdive","name_expr_wdive_root","name_expr_wdive_write","name_expr_wdive_class",
255: "construct","construct_square","construct_round","construct_curly","any_constructor_code_value",
256: "constructor_code_value","constructor_code","codes__excluding_sole_str_literal",
257: "call","call_value","@1","@2","call_name","store_params","store_param","store_square_param",
258: "store_round_param","store_curly_param","store_code_param_parts","store_expr_param_parts",
259: "store_curly_param_parts","store_code_param_part","store_expr_param_part","store_curly_param_part",
260: "code_param_value","write_expr_value","name_expr_dive_code","name_path","name_step",
261: "name_advance1","name_advance2","name_expr_value","name_expr_subvar_value","name_expr_with_subvar_value",
1.11 parser 262: "name_square_code_value","subvar_ref_name_rdive","subvar_get_writes","subvar__get_write",
1.3 parser 263: "class_prefix","class_static_prefix","class_constructor_prefix","expr_value",
264: "expr","string_inside_quotes_value","write_string","void_value","empty", NULL
1.1 parser 265: };
266: #endif
267:
268: static const short yyr1[] = { 0,
1.67 paf 269: 60, 60, 61, 61, 62, 63, 63, 64, 65, 65,
270: 66, 66, 67, 68, 68, 69, 70, 70, 71, 72,
271: 72, 73, 73, 74, 74, 75, 75, 76, 76, 77,
272: 77, 78, 78, 78, 79, 80, 81, 81, 82, 83,
273: 83, 84, 85, 86, 86, 87, 88, 88, 88, 89,
274: 90, 91, 92, 92, 92, 93, 94, 95, 96, 96,
275: 96, 97, 98, 99, 99, 100, 102, 103, 101, 104,
276: 105, 105, 106, 106, 106, 107, 108, 109, 110, 110,
277: 111, 111, 112, 112, 113, 114, 115, 116, 116, 116,
278: 117, 118, 118, 119, 119, 120, 121, 122, 122, 123,
279: 123, 123, 123, 124, 125, 126, 127, 128, 128, 129,
280: 130, 130, 131, 132, 133, 134, 134, 134, 134, 134,
281: 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
282: 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
283: 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
284: 134, 134, 134, 134, 134, 134, 135, 136, 137, 138
1.1 parser 285: };
286:
287: static const short yyr2[] = { 0,
288: 1, 1, 1, 2, 1, 1, 1, 4, 1, 1,
289: 1, 2, 2, 1, 1, 7, 1, 1, 3, 1,
290: 1, 1, 3, 1, 1, 1, 1, 1, 2, 1,
291: 1, 1, 1, 1, 1, 2, 2, 1, 3, 1,
292: 1, 1, 2, 1, 2, 3, 1, 1, 1, 1,
293: 2, 2, 1, 1, 1, 3, 3, 3, 1, 1,
294: 1, 1, 1, 1, 2, 1, 0, 0, 6, 1,
295: 1, 2, 1, 1, 1, 3, 3, 3, 1, 3,
296: 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
297: 1, 1, 2, 1, 2, 2, 1, 1, 2, 1,
1.3 parser 298: 1, 1, 1, 2, 2, 3, 1, 1, 2, 2,
299: 1, 1, 2, 2, 1, 1, 1, 1, 3, 3,
1.11 parser 300: 3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
1.1 parser 301: 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
302: 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1.67 paf 303: 3, 3, 3, 3, 3, 3, 1, 1, 0, 0
1.1 parser 304: };
305:
1.67 paf 306: static const short yydefact[] = { 160,
307: 158, 0, 0, 67, 2, 1, 3, 6, 7, 5,
1.1 parser 308: 27, 28, 31, 32, 35, 33, 34, 66, 30, 26,
1.3 parser 309: 0, 100, 0, 0, 0, 0, 36, 38, 0, 40,
310: 41, 42, 0, 47, 48, 49, 50, 0, 94, 0,
311: 44, 92, 101, 102, 103, 0, 111, 112, 0, 4,
1.67 paf 312: 29, 160, 160, 160, 99, 0, 113, 105, 108, 0,
1.5 parser 313: 107, 104, 0, 0, 98, 0, 100, 51, 0, 92,
1.67 paf 314: 37, 159, 160, 0, 46, 53, 54, 55, 100, 95,
1.3 parser 315: 45, 93, 96, 43, 52, 114, 70, 68, 15, 8,
1.67 paf 316: 10, 11, 0, 9, 22, 0, 21, 20, 160, 18,
317: 17, 110, 109, 106, 39, 93, 158, 0, 31, 0,
1.3 parser 318: 61, 62, 63, 59, 0, 116, 0, 0, 0, 0,
1.67 paf 319: 0, 0, 0, 0, 0, 0, 160, 160, 117, 118,
1.11 parser 320: 0, 115, 0, 12, 14, 13, 19, 0, 25, 0,
1.74 paf 321: 24, 65, 56, 58, 126, 127, 128, 129, 123, 122,
322: 124, 125, 0, 157, 0, 0, 57, 0, 0, 0,
1.1 parser 323: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1.11 parser 324: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1.67 paf 325: 0, 0, 0, 0, 159, 160, 0, 0, 71, 73,
326: 74, 75, 23, 160, 121, 119, 120, 141, 142, 143,
327: 140, 146, 147, 148, 149, 136, 137, 150, 151, 152,
1.74 paf 328: 153, 154, 155, 156, 144, 145, 139, 138, 131, 130,
329: 132, 133, 135, 134, 158, 90, 0, 79, 85, 88,
1.67 paf 330: 87, 0, 83, 0, 81, 86, 91, 69, 72, 16,
331: 76, 159, 160, 78, 0, 77, 80, 84, 82, 0,
332: 0, 0
1.1 parser 333: };
334:
1.67 paf 335: static const short yydefgoto[] = { 250,
1.3 parser 336: 5, 6, 7, 8, 90, 91, 92, 93, 9, 99,
1.11 parser 337: 54, 96, 97, 140, 154, 11, 12, 13, 14, 129,
1.3 parser 338: 27, 28, 29, 30, 31, 32, 16, 33, 34, 35,
1.67 paf 339: 36, 75, 76, 77, 78, 110, 226, 112, 113, 17,
340: 130, 49, 133, 88, 188, 189, 190, 191, 192, 227,
341: 234, 232, 228, 235, 233, 229, 236, 37, 64, 39,
1.5 parser 342: 40, 41, 65, 43, 44, 45, 62, 58, 59, 66,
1.67 paf 343: 47, 48, 237, 132, 155, 19, 230, 20
1.1 parser 344: };
345:
1.74 paf 346: static const short yypact[] = { 13,
347: -32768, 24, 98,-32768, 36,-32768,-32768,-32768,-32768,-32768,
1.67 paf 348: 14,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1.74 paf 349: -26, 39, 14, 44, 45, 100,-32768,-32768, 47,-32768,
350: -32768,-32768, 52,-32768,-32768,-32768,-32768, 118,-32768, 59,
351: -32768, 4,-32768,-32768,-32768, 118, -3,-32768, 45,-32768,
352: -32768, 101, 113, 71,-32768, 44,-32768, 70,-32768, 32,
353: -32768,-32768, 73, 118, 83, 118, 70,-32768, 100, 83,
354: -32768, 27, 14, 57,-32768,-32768,-32768,-32768, 1,-32768,
355: -32768, 4,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
356: 20,-32768, 78, 91,-32768, 90, 94,-32768, 135,-32768,
357: -32768,-32768,-32768,-32768,-32768, 83, 92, 14, -22, 106,
358: -32768,-32768,-32768,-32768, 115,-32768, 57, 57, 57, 57,
359: 57, 57, 57, 57, 105, 57, 14, 14,-32768,-32768,
360: 114, 281, 72,-32768,-32768,-32768,-32768, 142,-32768, 107,
361: -32768, 14,-32768,-32768, 440, 440, 440, 440,-32768,-32768,
362: -32768,-32768, 236,-32768, 112, 120,-32768, 57, 57, 57,
363: 57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
364: 57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
365: 57, 57, 57, 57, 41, 14, 57, 5,-32768,-32768,
366: -32768,-32768,-32768, 14,-32768,-32768,-32768, 371, 343, 312,
367: 244, 399, 399, 412, 412, 136, 136, 399, 399, 399,
368: 399, 412, 412, 440, 399, 399, 447, 453, 93, 93,
369: -32768,-32768,-32768,-32768, -11,-32768, 19,-32768,-32768,-32768,
370: -32768, -10,-32768, -33,-32768,-32768,-32768,-32768,-32768,-32768,
371: -32768, 41, 14,-32768, 57,-32768,-32768,-32768,-32768, 180,
1.67 paf 372: 181,-32768
1.1 parser 373: };
374:
375: static const short yypgoto[] = {-32768,
1.74 paf 376: -32768,-32768, 177,-32768,-32768,-32768, 99,-32768,-32768,-32768,
377: 129,-32768,-32768,-32768, 3, -18, -7, -71,-32768, 0,
378: -32768,-32768, -6,-32768,-32768, -37,-32768,-32768,-32768,-32768,
379: -32768,-32768,-32768,-32768,-32768,-32768, 119,-32768,-32768,-32768,
380: 2,-32768,-32768,-32768,-32768, -4,-32768,-32768,-32768,-32768,
381: -32768,-32768, -50, -52, -48,-32768,-32768, -16, 95, -23,
382: -32768, -24, 9,-32768,-32768,-32768, 169,-32768, 168, 224,
383: -32768,-32768, 154, 40, 102,-32768, 157, -20
1.1 parser 384: };
385:
386:
1.74 paf 387: #define YYLAST 494
1.1 parser 388:
389:
390: static const short yytable[] = { 15,
1.74 paf 391: 109, 18, 10, 51, 60, 55, -98, 238, 84, 68,
392: 15, 42, 18, 81, 80, 245, 1, 1, 63, 52,
393: 53, 246, 15, 89, 18, -64, -64, 21, 84, 85,
394: 107, 94, 98, 101, 70, 1, -89, -89, 243, 81,
395: 80, 244, 87, 55, 225, 80, 82, 61, 22, 71,
396: 56, 185, 51, 86, 42, 186, -97, 2, 187, 15,
397: 116, 18, 3, 3, 108, -160, 241, 242, 4, 4,
398: 135, 15, 15, 18, 18, 115, 3, 106, 141, 104,
399: 2, 3, 4, 117, 118, 119, 120, 4, 56, 142,
400: 3, 23, 121, 122, 24, 57, 4, 38, 72, 123,
401: 124, 22, 73, 67, 89, 74, 125, 15, 22, 18,
402: 126, 83, 4, 109, 127, 128, 95, 53, 185, 56,
403: 69, 79, 186, 136, 105, 187, 15, 15, 18, 18,
404: 181, 182, 183, 184, 51, -97, -14, 137, 139, -60,
405: 38, 15, 138, 18, 23, 193, 23, 24, 25, 24,
406: 26, 23, 194, 143, 24, 25, 145, 146, 147, 148,
407: 149, 150, 151, 152, 23, 153, 144, 24, 157, 196,
408: 109, 179, 180, 181, 182, 183, 184, 108, 197, 251,
409: 252, 50, 100, 239, 15, 15, 18, 18, 231, 134,
410: 111, 247, 249, 15, 248, 18, 240, 198, 199, 200,
1.5 parser 411: 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
1.25 paf 412: 211, 212, 213, 214, 215, 216, 217, 218, 219, 220,
1.74 paf 413: 221, 222, 223, 224, 102, 103, 46, 131, 114, 156,
414: 0, 0, 0, 0, 108, 0, 0, 0, 0, 0,
1.67 paf 415: 0, 15, 15, 18, 18, 231, 158, 159, 160, 161,
1.65 paf 416: 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
1.74 paf 417: 172, 173, 166, 167, 0, 0, 174, 175, 176, 177,
418: 178, 179, 180, 181, 182, 183, 184, 177, 178, 179,
419: 180, 181, 182, 183, 184, 0, 0, 0, 0, 0,
1.67 paf 420: 195, 158, 159, 160, 161, 162, 163, 164, 165, 166,
421: 167, 168, 169, 170, 171, 172, 173, 0, 0, 0,
1.74 paf 422: 0, 174, 175, 176, 177, 178, 179, 180, 181, 182,
423: 183, 184, 158, 159, 0, 161, 162, 163, 164, 165,
424: 166, 167, 168, 169, 170, 171, 172, 173, 0, 0,
425: 0, 0, 174, 175, 176, 177, 178, 179, 180, 181,
426: 182, 183, 184, 158, 0, 0, 161, 162, 163, 164,
427: 165, 166, 167, 168, 169, 170, 171, 172, 173, 0,
428: 0, 0, 0, 174, 175, 176, 177, 178, 179, 180,
429: 181, 182, 183, 184, 161, 162, 163, 164, 165, 166,
430: 167, 168, 169, 170, 171, 172, 173, 0, 0, 0,
431: 0, 174, 175, 176, 177, 178, 179, 180, 181, 182,
432: 183, 184, 161, 0, 0, 164, 165, 166, 167, 0,
433: 0, 0, 0, 172, 173, 161, 0, 0, 0, 174,
434: 166, 167, 177, 178, 179, 180, 181, 182, 183, 184,
435: 0, 0, 174, 0, 0, 177, 178, 179, 180, 181,
1.67 paf 436: 182, 183, 184, 161, 0, 0, 0, 0, 166, 167,
1.74 paf 437: 0, 0, 0, 0, 0, 166, 167, 0, 0, 0,
438: 0, 166, 167, 177, 178, 179, 180, 181, 182, 183,
439: 184, 178, 179, 180, 181, 182, 183, 184, 179, 180,
440: 181, 182, 183, 184
1.1 parser 441: };
442:
443: static const short yycheck[] = { 0,
1.74 paf 444: 72, 0, 0, 11, 23, 5, 3, 3, 46, 26,
445: 11, 3, 11, 38, 38, 49, 4, 4, 25, 46,
446: 47, 55, 23, 4, 23, 48, 49, 4, 66, 46,
447: 4, 52, 53, 54, 26, 4, 48, 49, 49, 64,
448: 64, 52, 49, 5, 4, 69, 38, 4, 4, 3,
449: 50, 47, 60, 57, 46, 51, 53, 45, 54, 60,
450: 4, 60, 50, 50, 72, 46, 48, 49, 56, 56,
451: 91, 72, 73, 72, 73, 73, 50, 69, 99, 48,
452: 45, 50, 56, 27, 28, 29, 30, 56, 50, 108,
453: 50, 47, 36, 37, 50, 57, 56, 3, 47, 43,
454: 44, 4, 51, 4, 4, 54, 50, 108, 4, 108,
455: 54, 53, 56, 185, 58, 59, 4, 47, 47, 50,
456: 26, 4, 51, 46, 52, 54, 127, 128, 127, 128,
457: 38, 39, 40, 41, 142, 53, 46, 48, 4, 48,
458: 46, 142, 49, 142, 47, 4, 47, 50, 51, 50,
459: 53, 47, 46, 48, 50, 51, 117, 118, 119, 120,
460: 121, 122, 123, 124, 47, 126, 52, 50, 55, 58,
461: 242, 36, 37, 38, 39, 40, 41, 185, 59, 0,
462: 0, 5, 54, 188, 185, 186, 185, 186, 186, 91,
463: 72, 242, 245, 194, 243, 194, 194, 158, 159, 160,
1.67 paf 464: 161, 162, 163, 164, 165, 166, 167, 168, 169, 170,
465: 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
1.74 paf 466: 181, 182, 183, 184, 56, 58, 3, 74, 72, 128,
467: -1, -1, -1, -1, 242, -1, -1, -1, -1, -1,
1.67 paf 468: -1, 242, 243, 242, 243, 243, 11, 12, 13, 14,
1.65 paf 469: 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1.74 paf 470: 25, 26, 19, 20, -1, -1, 31, 32, 33, 34,
471: 35, 36, 37, 38, 39, 40, 41, 34, 35, 36,
472: 37, 38, 39, 40, 41, -1, -1, -1, -1, -1,
1.67 paf 473: 55, 11, 12, 13, 14, 15, 16, 17, 18, 19,
474: 20, 21, 22, 23, 24, 25, 26, -1, -1, -1,
1.74 paf 475: -1, 31, 32, 33, 34, 35, 36, 37, 38, 39,
476: 40, 41, 11, 12, -1, 14, 15, 16, 17, 18,
477: 19, 20, 21, 22, 23, 24, 25, 26, -1, -1,
478: -1, -1, 31, 32, 33, 34, 35, 36, 37, 38,
479: 39, 40, 41, 11, -1, -1, 14, 15, 16, 17,
480: 18, 19, 20, 21, 22, 23, 24, 25, 26, -1,
481: -1, -1, -1, 31, 32, 33, 34, 35, 36, 37,
482: 38, 39, 40, 41, 14, 15, 16, 17, 18, 19,
483: 20, 21, 22, 23, 24, 25, 26, -1, -1, -1,
484: -1, 31, 32, 33, 34, 35, 36, 37, 38, 39,
485: 40, 41, 14, -1, -1, 17, 18, 19, 20, -1,
486: -1, -1, -1, 25, 26, 14, -1, -1, -1, 31,
487: 19, 20, 34, 35, 36, 37, 38, 39, 40, 41,
488: -1, -1, 31, -1, -1, 34, 35, 36, 37, 38,
489: 39, 40, 41, 14, -1, -1, -1, -1, 19, 20,
490: -1, -1, -1, -1, -1, 19, 20, -1, -1, -1,
491: -1, 19, 20, 34, 35, 36, 37, 38, 39, 40,
492: 41, 35, 36, 37, 38, 39, 40, 41, 36, 37,
493: 38, 39, 40, 41
1.1 parser 494: };
495: #define YYPURE 1
496:
497: /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1.15 parser 498: #line 3 "/usr/share/bison.simple"
1.1 parser 499: /* This file comes from bison-1.28. */
500:
501: /* Skeleton output parser for bison,
502: Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
503:
504: This program is free software; you can redistribute it and/or modify
505: it under the terms of the GNU General Public License as published by
506: the Free Software Foundation; either version 2, or (at your option)
507: any later version.
508:
509: This program is distributed in the hope that it will be useful,
510: but WITHOUT ANY WARRANTY; without even the implied warranty of
511: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
512: GNU General Public License for more details.
513:
514: You should have received a copy of the GNU General Public License
515: along with this program; if not, write to the Free Software
516: Foundation, Inc., 59 Temple Place - Suite 330,
517: Boston, MA 02111-1307, USA. */
518:
519: /* As a special exception, when this file is copied by Bison into a
520: Bison output file, you may use that output file without restriction.
521: This special exception was added by the Free Software Foundation
522: in version 1.24 of Bison. */
523:
524: /* This is the parser code that is written into each bison parser
525: when the %semantic_parser declaration is not specified in the grammar.
526: It was written by Richard Stallman by simplifying the hairy parser
527: used when %semantic_parser is specified. */
528:
529: #ifndef YYSTACK_USE_ALLOCA
530: #ifdef alloca
531: #define YYSTACK_USE_ALLOCA
532: #else /* alloca not defined */
533: #ifdef __GNUC__
534: #define YYSTACK_USE_ALLOCA
535: #define alloca __builtin_alloca
536: #else /* not GNU C. */
537: #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
538: #define YYSTACK_USE_ALLOCA
539: #include <alloca.h>
540: #else /* not sparc */
541: /* We think this test detects Watcom and Microsoft C. */
542: /* This used to test MSDOS, but that is a bad idea
543: since that symbol is in the user namespace. */
544: #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
545: #if 0 /* No need for malloc.h, which pollutes the namespace;
546: instead, just don't use alloca. */
547: #include <malloc.h>
548: #endif
549: #else /* not MSDOS, or __TURBOC__ */
550: #if defined(_AIX)
551: /* I don't know what this was needed for, but it pollutes the namespace.
552: So I turned it off. rms, 2 May 1997. */
553: /* #include <malloc.h> */
554: #pragma alloca
555: #define YYSTACK_USE_ALLOCA
556: #else /* not MSDOS, or __TURBOC__, or _AIX */
557: #if 0
558: #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
559: and on HPUX 10. Eventually we can turn this on. */
560: #define YYSTACK_USE_ALLOCA
561: #define alloca __builtin_alloca
562: #endif /* __hpux */
563: #endif
564: #endif /* not _AIX */
565: #endif /* not MSDOS, or __TURBOC__ */
566: #endif /* not sparc */
567: #endif /* not GNU C */
568: #endif /* alloca not defined */
569: #endif /* YYSTACK_USE_ALLOCA not defined */
570:
571: #ifdef YYSTACK_USE_ALLOCA
572: #define YYSTACK_ALLOC alloca
573: #else
574: #define YYSTACK_ALLOC malloc
575: #endif
576:
577: /* Note: there must be only one dollar sign in this file.
578: It is replaced by the list of actions, each action
579: as one case of the switch. */
580:
581: #define yyerrok (yyerrstatus = 0)
582: #define yyclearin (yychar = YYEMPTY)
583: #define YYEMPTY -2
584: #define YYEOF 0
585: #define YYACCEPT goto yyacceptlab
586: #define YYABORT goto yyabortlab
587: #define YYERROR goto yyerrlab1
588: /* Like YYERROR except do call yyerror.
589: This remains here temporarily to ease the
590: transition to the new meaning of YYERROR, for GCC.
591: Once GCC version 2 has supplanted version 1, this can go. */
592: #define YYFAIL goto yyerrlab
593: #define YYRECOVERING() (!!yyerrstatus)
594: #define YYBACKUP(token, value) \
595: do \
596: if (yychar == YYEMPTY && yylen == 1) \
597: { yychar = (token), yylval = (value); \
598: yychar1 = YYTRANSLATE (yychar); \
599: YYPOPSTACK; \
600: goto yybackup; \
601: } \
602: else \
603: { yyerror ("syntax error: cannot back up"); YYERROR; } \
604: while (0)
605:
606: #define YYTERROR 1
607: #define YYERRCODE 256
608:
609: #ifndef YYPURE
610: #define YYLEX yylex()
611: #endif
612:
613: #ifdef YYPURE
614: #ifdef YYLSP_NEEDED
615: #ifdef YYLEX_PARAM
616: #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
617: #else
618: #define YYLEX yylex(&yylval, &yylloc)
619: #endif
620: #else /* not YYLSP_NEEDED */
621: #ifdef YYLEX_PARAM
622: #define YYLEX yylex(&yylval, YYLEX_PARAM)
623: #else
624: #define YYLEX yylex(&yylval)
625: #endif
626: #endif /* not YYLSP_NEEDED */
627: #endif
628:
629: /* If nonreentrant, generate the variables here */
630:
631: #ifndef YYPURE
632:
633: int yychar; /* the lookahead symbol */
634: YYSTYPE yylval; /* the semantic value of the */
635: /* lookahead symbol */
636:
637: #ifdef YYLSP_NEEDED
638: YYLTYPE yylloc; /* location data for the lookahead */
639: /* symbol */
640: #endif
641:
642: int yynerrs; /* number of parse errors so far */
643: #endif /* not YYPURE */
644:
645: #if YYDEBUG != 0
646: int yydebug; /* nonzero means print parse trace */
647: /* Since this is uninitialized, it does not stop multiple parsers
648: from coexisting. */
649: #endif
650:
651: /* YYINITDEPTH indicates the initial size of the parser's stacks */
652:
653: #ifndef YYINITDEPTH
654: #define YYINITDEPTH 200
655: #endif
656:
657: /* YYMAXDEPTH is the maximum size the stacks can grow to
658: (effective only if the built-in stack extension method is used). */
659:
660: #if YYMAXDEPTH == 0
661: #undef YYMAXDEPTH
662: #endif
663:
664: #ifndef YYMAXDEPTH
665: #define YYMAXDEPTH 10000
666: #endif
667:
668: /* Define __yy_memcpy. Note that the size argument
669: should be passed with type unsigned int, because that is what the non-GCC
670: definitions require. With GCC, __builtin_memcpy takes an arg
671: of type size_t, but it can handle unsigned int. */
672:
673: #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
674: #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
675: #else /* not GNU C or C++ */
676: #ifndef __cplusplus
677:
678: /* This is the most reliable way to avoid incompatibilities
679: in available built-in functions on various systems. */
680: static void
681: __yy_memcpy (to, from, count)
682: char *to;
683: char *from;
684: unsigned int count;
685: {
686: register char *f = from;
687: register char *t = to;
688: register int i = count;
689:
690: while (i-- > 0)
691: *t++ = *f++;
692: }
693:
694: #else /* __cplusplus */
695:
696: /* This is the most reliable way to avoid incompatibilities
697: in available built-in functions on various systems. */
698: static void
699: __yy_memcpy (char *to, char *from, unsigned int count)
700: {
701: register char *t = to;
702: register char *f = from;
703: register int i = count;
704:
705: while (i-- > 0)
706: *t++ = *f++;
707: }
708:
709: #endif
710: #endif
711:
1.15 parser 712: #line 217 "/usr/share/bison.simple"
1.1 parser 713:
714: /* The user can define YYPARSE_PARAM as the name of an argument to be passed
715: into yyparse. The argument should have type void *.
716: It should actually point to an object.
717: Grammar actions can access the variable by casting it
718: to the proper pointer type. */
719:
720: #ifdef YYPARSE_PARAM
721: #ifdef __cplusplus
722: #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
723: #define YYPARSE_PARAM_DECL
724: #else /* not __cplusplus */
725: #define YYPARSE_PARAM_ARG YYPARSE_PARAM
726: #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
727: #endif /* not __cplusplus */
728: #else /* not YYPARSE_PARAM */
729: #define YYPARSE_PARAM_ARG
730: #define YYPARSE_PARAM_DECL
731: #endif /* not YYPARSE_PARAM */
732:
733: /* Prevent warning if -Wstrict-prototypes. */
734: #ifdef __GNUC__
735: #ifdef YYPARSE_PARAM
736: int yyparse (void *);
737: #else
738: int yyparse (void);
739: #endif
740: #endif
741:
742: int
743: yyparse(YYPARSE_PARAM_ARG)
744: YYPARSE_PARAM_DECL
745: {
746: register int yystate;
747: register int yyn;
748: register short *yyssp;
749: register YYSTYPE *yyvsp;
750: int yyerrstatus; /* number of tokens to shift before error messages enabled */
751: int yychar1 = 0; /* lookahead token as an internal (translated) token number */
752:
753: short yyssa[YYINITDEPTH]; /* the state stack */
754: YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
755:
756: short *yyss = yyssa; /* refer to the stacks thru separate pointers */
757: YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
758:
759: #ifdef YYLSP_NEEDED
760: YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
761: YYLTYPE *yyls = yylsa;
762: YYLTYPE *yylsp;
763:
764: #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
765: #else
766: #define YYPOPSTACK (yyvsp--, yyssp--)
767: #endif
768:
769: int yystacksize = YYINITDEPTH;
770: int yyfree_stacks = 0;
771:
772: #ifdef YYPURE
773: int yychar;
774: YYSTYPE yylval;
775: int yynerrs;
776: #ifdef YYLSP_NEEDED
777: YYLTYPE yylloc;
778: #endif
779: #endif
780:
781: YYSTYPE yyval; /* the variable used to return */
782: /* semantic values from the action */
783: /* routines */
784:
785: int yylen;
786:
787: #if YYDEBUG != 0
788: if (yydebug)
789: fprintf(stderr, "Starting parse\n");
790: #endif
791:
792: yystate = 0;
793: yyerrstatus = 0;
794: yynerrs = 0;
795: yychar = YYEMPTY; /* Cause a token to be read. */
796:
797: /* Initialize stack pointers.
798: Waste one element of value and location stack
799: so that they stay on the same level as the state stack.
800: The wasted elements are never initialized. */
801:
802: yyssp = yyss - 1;
803: yyvsp = yyvs;
804: #ifdef YYLSP_NEEDED
805: yylsp = yyls;
806: #endif
807:
808: /* Push a new state, which is found in yystate . */
809: /* In all cases, when you get here, the value and location stacks
810: have just been pushed. so pushing a state here evens the stacks. */
811: yynewstate:
812:
813: *++yyssp = yystate;
814:
815: if (yyssp >= yyss + yystacksize - 1)
816: {
817: /* Give user a chance to reallocate the stack */
818: /* Use copies of these so that the &'s don't force the real ones into memory. */
819: YYSTYPE *yyvs1 = yyvs;
820: short *yyss1 = yyss;
821: #ifdef YYLSP_NEEDED
822: YYLTYPE *yyls1 = yyls;
823: #endif
824:
825: /* Get the current used size of the three stacks, in elements. */
826: int size = yyssp - yyss + 1;
827:
828: #ifdef yyoverflow
829: /* Each stack pointer address is followed by the size of
830: the data in use in that stack, in bytes. */
831: #ifdef YYLSP_NEEDED
832: /* This used to be a conditional around just the two extra args,
833: but that might be undefined if yyoverflow is a macro. */
834: yyoverflow("parser stack overflow",
835: &yyss1, size * sizeof (*yyssp),
836: &yyvs1, size * sizeof (*yyvsp),
837: &yyls1, size * sizeof (*yylsp),
838: &yystacksize);
839: #else
840: yyoverflow("parser stack overflow",
841: &yyss1, size * sizeof (*yyssp),
842: &yyvs1, size * sizeof (*yyvsp),
843: &yystacksize);
844: #endif
845:
846: yyss = yyss1; yyvs = yyvs1;
847: #ifdef YYLSP_NEEDED
848: yyls = yyls1;
849: #endif
850: #else /* no yyoverflow */
851: /* Extend the stack our own way. */
852: if (yystacksize >= YYMAXDEPTH)
853: {
854: yyerror("parser stack overflow");
855: if (yyfree_stacks)
856: {
857: free (yyss);
858: free (yyvs);
859: #ifdef YYLSP_NEEDED
860: free (yyls);
861: #endif
862: }
863: return 2;
864: }
865: yystacksize *= 2;
866: if (yystacksize > YYMAXDEPTH)
867: yystacksize = YYMAXDEPTH;
868: #ifndef YYSTACK_USE_ALLOCA
869: yyfree_stacks = 1;
870: #endif
871: yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
872: __yy_memcpy ((char *)yyss, (char *)yyss1,
873: size * (unsigned int) sizeof (*yyssp));
874: yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
875: __yy_memcpy ((char *)yyvs, (char *)yyvs1,
876: size * (unsigned int) sizeof (*yyvsp));
877: #ifdef YYLSP_NEEDED
878: yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
879: __yy_memcpy ((char *)yyls, (char *)yyls1,
880: size * (unsigned int) sizeof (*yylsp));
881: #endif
882: #endif /* no yyoverflow */
883:
884: yyssp = yyss + size - 1;
885: yyvsp = yyvs + size - 1;
886: #ifdef YYLSP_NEEDED
887: yylsp = yyls + size - 1;
888: #endif
889:
890: #if YYDEBUG != 0
891: if (yydebug)
892: fprintf(stderr, "Stack size increased to %d\n", yystacksize);
893: #endif
894:
895: if (yyssp >= yyss + yystacksize - 1)
896: YYABORT;
897: }
898:
899: #if YYDEBUG != 0
900: if (yydebug)
901: fprintf(stderr, "Entering state %d\n", yystate);
902: #endif
903:
904: goto yybackup;
905: yybackup:
906:
907: /* Do appropriate processing given the current state. */
908: /* Read a lookahead token if we need one and don't already have one. */
909: /* yyresume: */
910:
911: /* First try to decide what to do without reference to lookahead token. */
912:
913: yyn = yypact[yystate];
914: if (yyn == YYFLAG)
915: goto yydefault;
916:
917: /* Not known => get a lookahead token if don't already have one. */
918:
919: /* yychar is either YYEMPTY or YYEOF
920: or a valid token in external form. */
921:
922: if (yychar == YYEMPTY)
923: {
924: #if YYDEBUG != 0
925: if (yydebug)
926: fprintf(stderr, "Reading a token: ");
927: #endif
928: yychar = YYLEX;
929: }
930:
931: /* Convert token to internal form (in yychar1) for indexing tables with */
932:
933: if (yychar <= 0) /* This means end of input. */
934: {
935: yychar1 = 0;
936: yychar = YYEOF; /* Don't call YYLEX any more */
937:
938: #if YYDEBUG != 0
939: if (yydebug)
940: fprintf(stderr, "Now at end of input.\n");
941: #endif
942: }
943: else
944: {
945: yychar1 = YYTRANSLATE(yychar);
946:
947: #if YYDEBUG != 0
948: if (yydebug)
949: {
950: fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
951: /* Give the individual parser a way to print the precise meaning
952: of a token, for further debugging info. */
953: #ifdef YYPRINT
954: YYPRINT (stderr, yychar, yylval);
955: #endif
956: fprintf (stderr, ")\n");
957: }
958: #endif
959: }
960:
961: yyn += yychar1;
962: if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
963: goto yydefault;
964:
965: yyn = yytable[yyn];
966:
967: /* yyn is what to do for this token type in this state.
968: Negative => reduce, -yyn is rule number.
969: Positive => shift, yyn is new state.
970: New state is final state => don't bother to shift,
971: just return success.
972: 0, or most negative number => error. */
973:
974: if (yyn < 0)
975: {
976: if (yyn == YYFLAG)
977: goto yyerrlab;
978: yyn = -yyn;
979: goto yyreduce;
980: }
981: else if (yyn == 0)
982: goto yyerrlab;
983:
984: if (yyn == YYFINAL)
985: YYACCEPT;
986:
987: /* Shift the lookahead token. */
988:
989: #if YYDEBUG != 0
990: if (yydebug)
991: fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
992: #endif
993:
994: /* Discard the token being shifted unless it is eof. */
995: if (yychar != YYEOF)
996: yychar = YYEMPTY;
997:
998: *++yyvsp = yylval;
999: #ifdef YYLSP_NEEDED
1000: *++yylsp = yylloc;
1001: #endif
1002:
1003: /* count tokens shifted since error; after three, turn off error status. */
1004: if (yyerrstatus) yyerrstatus--;
1005:
1006: yystate = yyn;
1007: goto yynewstate;
1008:
1009: /* Do the default action for the current state. */
1010: yydefault:
1011:
1012: yyn = yydefact[yystate];
1013: if (yyn == 0)
1014: goto yyerrlab;
1015:
1016: /* Do a reduction. yyn is the number of a rule to reduce with. */
1017: yyreduce:
1018: yylen = yyr2[yyn];
1019: if (yylen > 0)
1020: yyval = yyvsp[1-yylen]; /* implement default value of the action */
1021:
1022: #if YYDEBUG != 0
1023: if (yydebug)
1024: {
1025: int i;
1026:
1027: fprintf (stderr, "Reducing via rule %d (line %d), ",
1028: yyn, yyrline[yyn]);
1029:
1030: /* Print the symbols being reduced, and their result. */
1031: for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1032: fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1033: fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1034: }
1035: #endif
1036:
1037:
1038: switch (yyn) {
1039:
1040: case 1:
1.84 paf 1041: #line 122 "compile.y"
1.1 parser 1042: {
1.84 paf 1043: Method& method=*new Method(Method::CT_ANY,
1.1 parser 1044: 0, 0, /*min, max numbered_params_count*/
1045: 0/*param_names*/, 0/*local_names*/,
1046: yyvsp[0]/*parser_code*/, 0/*native_code*/);
1.84 paf 1047: PC.cclass->add_method(PC.alias_method(main_method_name), method);
1.1 parser 1048: ;
1049: break;}
1050: case 8:
1.84 paf 1051: #line 137 "compile.y"
1.1 parser 1052: {
1.84 paf 1053: const String& command=*LA2S(*yyvsp[-2]);
1.1 parser 1054: YYSTYPE strings_code=yyvsp[0];
1.84 paf 1055: if(strings_code->count()<1*OPERATIONS_PER_OPVALUE) {
1.1 parser 1056: strcpy(PC.error, "@");
1057: strcat(PC.error, command.cstr());
1058: strcat(PC.error, " is empty");
1059: YYERROR;
1060: }
1061: if(command==CLASS_NAME) {
1.59 paf 1062: if(PC.cclass->base_class()) { // already changed from default?
1.1 parser 1063: strcpy(PC.error, "class already have a name '");
1064: strncat(PC.error, PC.cclass->name().cstr(), 100);
1065: strcat(PC.error, "'");
1066: YYERROR;
1067: }
1.84 paf 1068: if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) {
1.1 parser 1069: // new class' name
1.84 paf 1070: const String& name=*LA2S(*strings_code);
1.1 parser 1071: // creating the class
1.84 paf 1072: VStateless_class* cclass=new VClass;
1073: PC.cclass=cclass;
1074: PC.cclass->set_name(name);
1.1 parser 1075: // append to request's classes
1.84 paf 1076: PC.request.classes().put(name, cclass);
1.1 parser 1077: } else {
1.84 paf 1078: strcpy(PC.error, "@"CLASS_NAME" must contain only one line with class name (contains more then one)");
1.1 parser 1079: YYERROR;
1080: }
1081: } else if(command==USE_CONTROL_METHOD_NAME) {
1.84 paf 1082: for(size_t i=0; i<strings_code->count(); i+=OPERATIONS_PER_OPVALUE)
1083: PC.request.use_file(PC.request.main_class, *LA2S(*strings_code, i));
1.1 parser 1084: } else if(command==BASE_NAME) {
1.59 paf 1085: if(PC.cclass->base_class()) { // already changed from default?
1.1 parser 1086: strcpy(PC.error, "class already have a base '");
1.59 paf 1087: strncat(PC.error, PC.cclass->base_class()->name().cstr(), 100);
1.1 parser 1088: strcat(PC.error, "'");
1089: YYERROR;
1090: }
1.84 paf 1091: if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) {
1092: const String& base_name=*LA2S(*strings_code);
1093: if(Value* base_class_value=PC.request.classes().get(base_name)) {
1094: // @CLASS == @BASE sanity check
1095: if(VStateless_class *base_class=base_class_value->get_class()) {
1096: if(PC.cclass==base_class) {
1097: strcpy(PC.error, "@"CLASS_NAME" equals @"BASE_NAME);
1098: YYERROR;
1099: }
1100: PC.cclass->get_class()->set_base(base_class);
1101: } else { // they asked to derive from a class without methods ['env' & co]
1102: strcpy(PC.error, base_name.cstr());
1103: strcat(PC.error, ": you can not derive from this class in @"BASE_NAME);
1104: YYERROR;
1105: }
1106: } else {
1.1 parser 1107: strcpy(PC.error, base_name.cstr());
1108: strcat(PC.error, ": undefined class in @"BASE_NAME);
1109: YYERROR;
1110: }
1111: } else {
1112: strcpy(PC.error, "@"BASE_NAME" must contain sole name");
1113: YYERROR;
1114: }
1115: } else {
1116: strcpy(PC.error, "'");
1117: strncat(PC.error, command.cstr(), MAX_STRING/2);
1118: strcat(PC.error, "' invalid special name. valid names are "
1119: "'"CLASS_NAME"', '"USE_CONTROL_METHOD_NAME"' and '"BASE_NAME"'");
1120: YYERROR;
1121: }
1122: ;
1123: break;}
1124: case 12:
1.84 paf 1125: #line 209 "compile.y"
1126: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1127: break;}
1128: case 16:
1.84 paf 1129: #line 214 "compile.y"
1.1 parser 1130: {
1.84 paf 1131: const String& name=*LA2S(*yyvsp[-5]);
1.1 parser 1132:
1133: YYSTYPE params_names_code=yyvsp[-4];
1.84 paf 1134: ArrayString* params_names=0;
1135: if(int size=params_names_code->count()) {
1136: params_names=new ArrayString;
1137: for(int i=0; i<size; i+=OPERATIONS_PER_OPVALUE)
1138: *params_names+=LA2S(*params_names_code, i);
1.1 parser 1139: }
1140:
1141: YYSTYPE locals_names_code=yyvsp[-3];
1.84 paf 1142: ArrayString* locals_names=0;
1143: if(int size=locals_names_code->count()) {
1144: locals_names=new ArrayString;
1145: for(int i=0; i<size; i+=OPERATIONS_PER_OPVALUE)
1146: *locals_names+=LA2S(*locals_names_code, i);
1.1 parser 1147: }
1148:
1.84 paf 1149: Method& method=*new Method(
1150: //name,
1.1 parser 1151: Method::CT_ANY,
1152: 0, 0/*min,max numbered_params_count*/,
1153: params_names, locals_names,
1154: yyvsp[0], 0);
1.84 paf 1155: PC.cclass->add_method(PC.alias_method(name), method);
1.1 parser 1156: ;
1157: break;}
1158: case 19:
1.84 paf 1159: #line 243 "compile.y"
1.1 parser 1160: {yyval=yyvsp[-1];
1161: break;}
1162: case 23:
1.84 paf 1163: #line 245 "compile.y"
1164: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1165: break;}
1166: case 29:
1.84 paf 1167: #line 253 "compile.y"
1168: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1169: break;}
1170: case 35:
1.84 paf 1171: #line 259 "compile.y"
1.1 parser 1172: {
1.48 paf 1173: yyval=yyvsp[0]; /* stack: resulting value */
1.84 paf 1174: changetail_or_append(*yyval,
1.51 paf 1175: OP_GET_ELEMENT, false, /*->*/OP_GET_ELEMENT__WRITE,
1176: /*or */OP_WRITE_VALUE
1.48 paf 1177: ); /* value=pop; wcontext.write(value) */
1.1 parser 1178: ;
1179: break;}
1180: case 36:
1.84 paf 1181: #line 266 "compile.y"
1.1 parser 1182: { yyval=yyvsp[0] ;
1183: break;}
1184: case 39:
1.84 paf 1185: #line 268 "compile.y"
1.1 parser 1186: { yyval=yyvsp[-1] ;
1187: break;}
1188: case 42:
1.84 paf 1189: #line 272 "compile.y"
1.1 parser 1190: {
1.84 paf 1191: yyval=N();
1192: ArrayOperation* diving_code=yyvsp[0];
1193: const String* first_name=LA2S(*diving_code);
1.37 paf 1194: // self.xxx... -> xxx...
1.84 paf 1195: // OP_VALUE+origin+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+...
1.1 parser 1196: if(first_name && *first_name==SELF_ELEMENT_NAME) {
1.84 paf 1197: O(*yyval, OP_WITH_SELF); /* stack: starting context */
1198: P(*yyval, *diving_code,
1.1 parser 1199: /* skip over... */
1.84 paf 1200: diving_code->count()>=4?4/*OP_VALUE+origin+string+OP_GET_ELEMENTx*/:3/*OP_+origin+string*/);
1.1 parser 1201: } else {
1.84 paf 1202: O(*yyval, OP_WITH_READ); /* stack: starting context */
1.37 paf 1203:
1.73 paf 1204: // ^if ELEMENT -> ^if ELEMENT_OR_OPERATOR
1.84 paf 1205: // OP_VALUE+origin+string+OP_GET_ELEMENT. -> OP_VALUE+origin+string+OP_GET_ELEMENT_OR_OPERATOR.
1206: if(PC.in_call_value && diving_code->count()==4)
1207: diving_code->put(4-1, OP_GET_ELEMENT_OR_OPERATOR);
1208: P(*yyval, *diving_code);
1.1 parser 1209: }
1210: /* diving code; stack: current context */
1211: ;
1212: break;}
1213: case 43:
1.84 paf 1214: #line 294 "compile.y"
1215: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1216: break;}
1217: case 45:
1.84 paf 1218: #line 295 "compile.y"
1219: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1220: break;}
1221: case 46:
1.84 paf 1222: #line 299 "compile.y"
1.1 parser 1223: {
1224: yyval=yyvsp[-1]; /* stack: context,name */
1.84 paf 1225: P(*yyval, *yyvsp[0]); /* stack: context,name,constructor_value */
1.1 parser 1226: ;
1227: break;}
1228: case 50:
1.84 paf 1229: #line 307 "compile.y"
1.1 parser 1230: {
1.84 paf 1231: yyval=N();
1232: ArrayOperation* diving_code=yyvsp[0];
1233: const String* first_name=LA2S(*diving_code);
1.37 paf 1234: // $self.xxx... -> $xxx...
1.84 paf 1235: // OP_VALUE+origin+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+...
1.1 parser 1236: if(first_name && *first_name==SELF_ELEMENT_NAME) {
1.84 paf 1237: O(*yyval, OP_WITH_SELF); /* stack: starting context */
1238: P(*yyval, *diving_code,
1.1 parser 1239: /* skip over... */
1.84 paf 1240: diving_code->count()>=4?4/*OP_VALUE+origin+string+OP_GET_ELEMENTx*/:3/*OP_+origin+string*/);
1.1 parser 1241: } else {
1.84 paf 1242: O(*yyval, OP_WITH_ROOT); /* stack: starting context */
1243: P(*yyval, *diving_code);
1.1 parser 1244: }
1245: /* diving code; stack: current context */
1246: ;
1247: break;}
1248: case 51:
1.84 paf 1249: #line 324 "compile.y"
1.1 parser 1250: {
1.84 paf 1251: yyval=N();
1252: O(*yyval, OP_WITH_WRITE); /* stack: starting context */
1253: P(*yyval, *yyvsp[0]); /* diving code; stack: context,name */
1.1 parser 1254: ;
1255: break;}
1256: case 52:
1.84 paf 1257: #line 329 "compile.y"
1258: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1259: break;}
1260: case 56:
1.84 paf 1261: #line 336 "compile.y"
1.1 parser 1262: {
1263: // stack: context, name
1264: yyval=yyvsp[-1]; // stack: context, name, value
1.84 paf 1265: O(*yyval, OP_CONSTRUCT_VALUE); /* value=pop; name=pop; context=pop; construct(context,name,value) */
1.1 parser 1266: ;
1267: break;}
1268: case 57:
1.84 paf 1269: #line 342 "compile.y"
1.1 parser 1270: {
1.84 paf 1271: yyval=N();
1272: O(*yyval, OP_PREPARE_TO_EXPRESSION);
1.1 parser 1273: // stack: context, name
1.84 paf 1274: P(*yyval, *yyvsp[-1]); // stack: context, name, value
1275: O(*yyval, OP_CONSTRUCT_EXPR); /* value=pop->as_expr_result; name=pop; context=pop; construct(context,name,value) */
1.1 parser 1276: ;
1277: break;}
1278: case 58:
1.84 paf 1279: #line 350 "compile.y"
1.1 parser 1280: {
1281: // stack: context, name
1.84 paf 1282: yyval=N();
1283: OA(*yyval, OP_CURLY_CODE__CONSTRUCT, yyvsp[-1]); /* code=pop; name=pop; context=pop; construct(context,name,junction(code)) */
1.1 parser 1284: ;
1285: break;}
1286: case 62:
1.84 paf 1287: #line 361 "compile.y"
1.1 parser 1288: {
1.84 paf 1289: yyval=N();
1290: OA(*yyval, OP_OBJECT_POOL, yyvsp[0]); /* stack: empty write context */
1.47 paf 1291: /* some code that writes to that context */
1292: /* context=pop; stack: context.value() */
1.1 parser 1293: ;
1294: break;}
1295: case 65:
1.84 paf 1296: #line 368 "compile.y"
1297: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1298: break;}
1299: case 66:
1.84 paf 1300: #line 372 "compile.y"
1.1 parser 1301: {
1302: yyval=yyvsp[0]; /* stack: value */
1.84 paf 1303: changetail_or_append(*yyval,
1.51 paf 1304: OP_CALL, true, /*->*/ OP_CALL__WRITE,
1305: /*or */OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */
1.1 parser 1306: ;
1307: break;}
1308: case 67:
1.84 paf 1309: #line 378 "compile.y"
1.33 paf 1310: {
1.39 paf 1311: PC.in_call_value=true;
1.33 paf 1312: ;
1.1 parser 1313: break;}
1314: case 68:
1.84 paf 1315: #line 381 "compile.y"
1.33 paf 1316: {
1.39 paf 1317: PC.in_call_value=false;
1.33 paf 1318: ;
1.1 parser 1319: break;}
1320: case 69:
1.84 paf 1321: #line 384 "compile.y"
1.1 parser 1322: { /* ^field.$method{vasya} */
1323: yyval=yyvsp[-3]; /* with_xxx,diving code; stack: context,method_junction */
1324:
1325: YYSTYPE params_code=yyvsp[-1];
1.84 paf 1326: if(params_code->count()==4) { // probably [] case. [OP_VALUE+origin+Void+STORE_PARAM]
1327: if(Value* value=LA2V(*params_code)) // it is OP_VALUE+origin+value?
1.1 parser 1328: if(!value->is_defined()) // value is VVoid?
1329: params_code=0; // ^zzz[] case. don't append lone empty param.
1.51 paf 1330: }
1331: /* stack: context, method_junction */
1.84 paf 1332: OA(*yyval, OP_CALL, params_code); // method_frame=make frame(pop junction); ncontext=pop; call(ncontext,method_frame) stack: value
1.1 parser 1333: ;
1334: break;}
1335: case 72:
1.84 paf 1336: #line 399 "compile.y"
1337: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1338: break;}
1339: case 76:
1.84 paf 1340: #line 405 "compile.y"
1.1 parser 1341: {yyval=yyvsp[-1];
1342: break;}
1343: case 77:
1.84 paf 1344: #line 406 "compile.y"
1.1 parser 1345: {yyval=yyvsp[-1];
1346: break;}
1347: case 78:
1.84 paf 1348: #line 407 "compile.y"
1.1 parser 1349: {yyval=yyvsp[-1];
1350: break;}
1351: case 80:
1.84 paf 1352: #line 410 "compile.y"
1353: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1354: break;}
1355: case 82:
1.84 paf 1356: #line 414 "compile.y"
1357: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1358: break;}
1359: case 84:
1.84 paf 1360: #line 418 "compile.y"
1361: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1362: break;}
1363: case 85:
1.84 paf 1364: #line 420 "compile.y"
1.1 parser 1365: {
1366: yyval=yyvsp[0];
1.84 paf 1367: O(*yyval, OP_STORE_PARAM);
1.1 parser 1368: ;
1369: break;}
1370: case 86:
1.84 paf 1371: #line 424 "compile.y"
1.1 parser 1372: {
1.84 paf 1373: yyval=N();
1374: OA(*yyval, OP_EXPR_CODE__STORE_PARAM, yyvsp[0]);
1.1 parser 1375: ;
1376: break;}
1377: case 87:
1.84 paf 1378: #line 428 "compile.y"
1.1 parser 1379: {
1.84 paf 1380: yyval=N();
1381: OA(*yyval, OP_CURLY_CODE__STORE_PARAM, yyvsp[0]);
1.1 parser 1382: ;
1383: break;}
1384: case 91:
1.84 paf 1385: #line 437 "compile.y"
1.1 parser 1386: {
1.84 paf 1387: yyval=N();
1388: O(*yyval, OP_PREPARE_TO_EXPRESSION);
1389: P(*yyval, *yyvsp[0]);
1390: O(*yyval, OP_WRITE_EXPR_RESULT);
1.1 parser 1391: ;
1392: break;}
1393: case 93:
1.84 paf 1394: #line 446 "compile.y"
1395: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1396: break;}
1397: case 95:
1.84 paf 1398: #line 448 "compile.y"
1399: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1400: break;}
1401: case 97:
1.84 paf 1402: #line 450 "compile.y"
1.1 parser 1403: {
1.33 paf 1404: // we know that name_advance1 not called from ^xxx context
1405: // so we'll not check for operator call possibility as we do in name_advance2
1406:
1.1 parser 1407: /* stack: context */
1408: yyval=yyvsp[0]; /* stack: context,name */
1.84 paf 1409: O(*yyval, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */
1.1 parser 1410: ;
1411: break;}
1412: case 98:
1.84 paf 1413: #line 458 "compile.y"
1.1 parser 1414: {
1415: /* stack: context */
1416: yyval=yyvsp[0]; /* stack: context,name */
1.84 paf 1417: O(*yyval, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */
1.1 parser 1418: ;
1419: break;}
1.3 parser 1420: case 104:
1.84 paf 1421: #line 471 "compile.y"
1.1 parser 1422: {
1423: yyval=yyvsp[0];
1.84 paf 1424: O(*yyval, OP_GET_ELEMENT);
1.1 parser 1425: ;
1426: break;}
1.3 parser 1427: case 105:
1.84 paf 1428: #line 475 "compile.y"
1.1 parser 1429: {
1.84 paf 1430: ArrayOperation* code;
1.47 paf 1431: {
1.84 paf 1432: change_string_literal_to_write_string_literal(*(code=yyvsp[-1]));
1433: P(*code, *yyvsp[0]);
1.47 paf 1434: }
1.84 paf 1435: yyval=N();
1436: OA(*yyval, OP_STRING_POOL, code);
1.1 parser 1437: ;
1438: break;}
1.3 parser 1439: case 106:
1.84 paf 1440: #line 484 "compile.y"
1.3 parser 1441: {
1.84 paf 1442: yyval=N();
1443: OA(*yyval, OP_OBJECT_POOL, yyvsp[-1]); /* stack: empty write context */
1.47 paf 1444: /* some code that writes to that context */
1445: /* context=pop; stack: context.value() */
1.3 parser 1446: ;
1447: break;}
1448: case 107:
1.84 paf 1449: #line 490 "compile.y"
1.1 parser 1450: {
1.84 paf 1451: yyval=N();
1452: O(*yyval, OP_WITH_READ);
1453: P(*yyval, *yyvsp[0]);
1.1 parser 1454: ;
1455: break;}
1.3 parser 1456: case 109:
1.84 paf 1457: #line 495 "compile.y"
1458: { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;
1.1 parser 1459: break;}
1.3 parser 1460: case 110:
1.84 paf 1461: #line 496 "compile.y"
1.1 parser 1462: {
1463: yyval=yyvsp[0];
1.84 paf 1464: O(*yyval, OP_GET_ELEMENT__WRITE);
1.1 parser 1465: ;
1466: break;}
1.3 parser 1467: case 113:
1.84 paf 1468: #line 505 "compile.y"
1.1 parser 1469: {
1470: yyval=yyvsp[-1]; // stack: class name string
1.84 paf 1471: if(*LA2S(*yyval) == BASE_NAME) { // pseudo BASE class
1472: if(VStateless_class* base=PC.cclass->base_class()) {
1473: change_string_literal_value(*yyval, base->name());
1.61 paf 1474: } else {
1475: strcpy(PC.error, "no base class declared");
1476: YYERROR;
1477: }
1478: }
1.84 paf 1479: O(*yyval, OP_GET_CLASS);
1.1 parser 1480: ;
1481: break;}
1.3 parser 1482: case 114:
1.84 paf 1483: #line 517 "compile.y"
1.1 parser 1484: {
1485: yyval=yyvsp[-1];
1.39 paf 1486: if(!PC.in_call_value) {
1.1 parser 1487: strcpy(PC.error, ":: not allowed here");
1488: YYERROR;
1489: }
1.84 paf 1490: O(*yyval, OP_PREPARE_TO_CONSTRUCT_OBJECT);
1.1 parser 1491: ;
1492: break;}
1.3 parser 1493: case 115:
1.84 paf 1494: #line 529 "compile.y"
1.1 parser 1495: {
1.43 paf 1496: // see OP_PREPARE_TO_EXPRESSION!!
1.84 paf 1497: if((yyval=yyvsp[0])->count()==2) // only one string literal in there?
1498: change_string_literal_to_double_literal(*yyval); // make that string literal Double
1.1 parser 1499: ;
1500: break;}
1.3 parser 1501: case 119:
1.84 paf 1502: #line 538 "compile.y"
1.1 parser 1503: { yyval = yyvsp[-1]; ;
1504: break;}
1.3 parser 1505: case 120:
1.84 paf 1506: #line 539 "compile.y"
1.1 parser 1507: { yyval = yyvsp[-1]; ;
1508: break;}
1.3 parser 1509: case 121:
1.84 paf 1510: #line 540 "compile.y"
1.1 parser 1511: { yyval = yyvsp[-1]; ;
1512: break;}
1.3 parser 1513: case 122:
1.84 paf 1514: #line 542 "compile.y"
1515: { yyval=yyvsp[0]; O(*yyval, OP_NEG) ;
1.1 parser 1516: break;}
1.3 parser 1517: case 123:
1.84 paf 1518: #line 543 "compile.y"
1.11 parser 1519: { yyval=yyvsp[0] ;
1.1 parser 1520: break;}
1.3 parser 1521: case 124:
1.84 paf 1522: #line 544 "compile.y"
1523: { yyval=yyvsp[0]; O(*yyval, OP_INV) ;
1.1 parser 1524: break;}
1.3 parser 1525: case 125:
1.84 paf 1526: #line 545 "compile.y"
1527: { yyval=yyvsp[0]; O(*yyval, OP_NOT) ;
1.1 parser 1528: break;}
1.3 parser 1529: case 126:
1.84 paf 1530: #line 546 "compile.y"
1531: { yyval=yyvsp[0]; O(*yyval, OP_DEF) ;
1.1 parser 1532: break;}
1.3 parser 1533: case 127:
1.84 paf 1534: #line 547 "compile.y"
1535: { yyval=yyvsp[0]; O(*yyval, OP_IN) ;
1.1 parser 1536: break;}
1.3 parser 1537: case 128:
1.84 paf 1538: #line 548 "compile.y"
1539: { yyval=yyvsp[0]; O(*yyval, OP_FEXISTS) ;
1.1 parser 1540: break;}
1.3 parser 1541: case 129:
1.84 paf 1542: #line 549 "compile.y"
1543: { yyval=yyvsp[0]; O(*yyval, OP_DEXISTS) ;
1.1 parser 1544: break;}
1.3 parser 1545: case 130:
1.84 paf 1546: #line 551 "compile.y"
1547: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_SUB) ;
1.1 parser 1548: break;}
1.3 parser 1549: case 131:
1.84 paf 1550: #line 552 "compile.y"
1551: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_ADD) ;
1.1 parser 1552: break;}
1.3 parser 1553: case 132:
1.84 paf 1554: #line 553 "compile.y"
1555: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MUL) ;
1.1 parser 1556: break;}
1.3 parser 1557: case 133:
1.84 paf 1558: #line 554 "compile.y"
1559: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_DIV) ;
1.1 parser 1560: break;}
1.3 parser 1561: case 134:
1.84 paf 1562: #line 555 "compile.y"
1563: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MOD) ;
1.1 parser 1564: break;}
1.3 parser 1565: case 135:
1.84 paf 1566: #line 556 "compile.y"
1567: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_INTDIV) ;
1.1 parser 1568: break;}
1.3 parser 1569: case 136:
1.84 paf 1570: #line 557 "compile.y"
1571: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SL) ;
1.67 paf 1572: break;}
1573: case 137:
1.84 paf 1574: #line 558 "compile.y"
1575: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SR) ;
1.67 paf 1576: break;}
1577: case 138:
1.84 paf 1578: #line 559 "compile.y"
1579: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_AND) ;
1.1 parser 1580: break;}
1.67 paf 1581: case 139:
1.84 paf 1582: #line 560 "compile.y"
1583: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_OR) ;
1.1 parser 1584: break;}
1.67 paf 1585: case 140:
1.84 paf 1586: #line 561 "compile.y"
1587: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_XOR) ;
1.1 parser 1588: break;}
1.67 paf 1589: case 141:
1.84 paf 1590: #line 562 "compile.y"
1591: { yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_AND) ;
1.1 parser 1592: break;}
1.67 paf 1593: case 142:
1.84 paf 1594: #line 563 "compile.y"
1595: { yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_OR) ;
1.1 parser 1596: break;}
1.67 paf 1597: case 143:
1.84 paf 1598: #line 564 "compile.y"
1599: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_LOG_XOR) ;
1.1 parser 1600: break;}
1.67 paf 1601: case 144:
1.84 paf 1602: #line 565 "compile.y"
1603: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LT) ;
1.1 parser 1604: break;}
1.67 paf 1605: case 145:
1.84 paf 1606: #line 566 "compile.y"
1607: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GT) ;
1.1 parser 1608: break;}
1.67 paf 1609: case 146:
1.84 paf 1610: #line 567 "compile.y"
1611: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LE) ;
1.1 parser 1612: break;}
1.67 paf 1613: case 147:
1.84 paf 1614: #line 568 "compile.y"
1615: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GE) ;
1.1 parser 1616: break;}
1.67 paf 1617: case 148:
1.84 paf 1618: #line 569 "compile.y"
1619: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_EQ) ;
1.1 parser 1620: break;}
1.67 paf 1621: case 149:
1.84 paf 1622: #line 570 "compile.y"
1623: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_NE) ;
1.1 parser 1624: break;}
1.67 paf 1625: case 150:
1.84 paf 1626: #line 571 "compile.y"
1627: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LT) ;
1.1 parser 1628: break;}
1.67 paf 1629: case 151:
1.84 paf 1630: #line 572 "compile.y"
1631: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GT) ;
1.1 parser 1632: break;}
1.67 paf 1633: case 152:
1.84 paf 1634: #line 573 "compile.y"
1635: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LE) ;
1.1 parser 1636: break;}
1.67 paf 1637: case 153:
1.84 paf 1638: #line 574 "compile.y"
1639: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GE) ;
1.1 parser 1640: break;}
1.67 paf 1641: case 154:
1.84 paf 1642: #line 575 "compile.y"
1643: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_EQ) ;
1.11 parser 1644: break;}
1.67 paf 1645: case 155:
1.84 paf 1646: #line 576 "compile.y"
1647: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_NE) ;
1.25 paf 1648: break;}
1.67 paf 1649: case 156:
1.84 paf 1650: #line 577 "compile.y"
1651: { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_IS) ;
1.1 parser 1652: break;}
1.67 paf 1653: case 157:
1.84 paf 1654: #line 580 "compile.y"
1.1 parser 1655: {
1.84 paf 1656: yyval=N();
1657: OA(*yyval, OP_STRING_POOL, yyvsp[0]); /* stack: empty write context */
1.47 paf 1658: /* some code that writes to that context */
1659: /* context=pop; stack: context.get_string() */
1.1 parser 1660: ;
1661: break;}
1.67 paf 1662: case 158:
1.84 paf 1663: #line 589 "compile.y"
1.1 parser 1664: {
1665: // optimized from OP_STRING+OP_WRITE_VALUE to OP_STRING__WRITE
1.84 paf 1666: change_string_literal_to_write_string_literal(*(yyval=yyvsp[0]))
1.1 parser 1667: ;
1668: break;}
1.67 paf 1669: case 159:
1.84 paf 1670: #line 594 "compile.y"
1671: { yyval=VL(new VVoid(), 0, 0, 0) ;
1.1 parser 1672: break;}
1.67 paf 1673: case 160:
1.84 paf 1674: #line 595 "compile.y"
1675: { yyval=N() ;
1.1 parser 1676: break;}
1677: }
1678: /* the action file gets copied in in place of this dollarsign */
1.15 parser 1679: #line 543 "/usr/share/bison.simple"
1.1 parser 1680:
1681: yyvsp -= yylen;
1682: yyssp -= yylen;
1683: #ifdef YYLSP_NEEDED
1684: yylsp -= yylen;
1685: #endif
1686:
1687: #if YYDEBUG != 0
1688: if (yydebug)
1689: {
1690: short *ssp1 = yyss - 1;
1691: fprintf (stderr, "state stack now");
1692: while (ssp1 != yyssp)
1693: fprintf (stderr, " %d", *++ssp1);
1694: fprintf (stderr, "\n");
1695: }
1696: #endif
1697:
1698: *++yyvsp = yyval;
1699:
1700: #ifdef YYLSP_NEEDED
1701: yylsp++;
1702: if (yylen == 0)
1703: {
1704: yylsp->first_line = yylloc.first_line;
1705: yylsp->first_column = yylloc.first_column;
1706: yylsp->last_line = (yylsp-1)->last_line;
1707: yylsp->last_column = (yylsp-1)->last_column;
1708: yylsp->text = 0;
1709: }
1710: else
1711: {
1712: yylsp->last_line = (yylsp+yylen-1)->last_line;
1713: yylsp->last_column = (yylsp+yylen-1)->last_column;
1714: }
1715: #endif
1716:
1717: /* Now "shift" the result of the reduction.
1718: Determine what state that goes to,
1719: based on the state we popped back to
1720: and the rule number reduced by. */
1721:
1722: yyn = yyr1[yyn];
1723:
1724: yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1725: if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1726: yystate = yytable[yystate];
1727: else
1728: yystate = yydefgoto[yyn - YYNTBASE];
1729:
1730: goto yynewstate;
1731:
1732: yyerrlab: /* here on detecting error */
1733:
1734: if (! yyerrstatus)
1735: /* If not already recovering from an error, report this error. */
1736: {
1737: ++yynerrs;
1738:
1739: #ifdef YYERROR_VERBOSE
1740: yyn = yypact[yystate];
1741:
1742: if (yyn > YYFLAG && yyn < YYLAST)
1743: {
1744: int size = 0;
1745: char *msg;
1746: int x, count;
1747:
1748: count = 0;
1749: /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1750: for (x = (yyn < 0 ? -yyn : 0);
1751: x < (sizeof(yytname) / sizeof(char *)); x++)
1752: if (yycheck[x + yyn] == x)
1753: size += strlen(yytname[x]) + 15, count++;
1754: msg = (char *) malloc(size + 15);
1755: if (msg != 0)
1756: {
1757: strcpy(msg, "parse error");
1758:
1759: if (count < 5)
1760: {
1761: count = 0;
1762: for (x = (yyn < 0 ? -yyn : 0);
1763: x < (sizeof(yytname) / sizeof(char *)); x++)
1764: if (yycheck[x + yyn] == x)
1765: {
1766: strcat(msg, count == 0 ? ", expecting `" : " or `");
1767: strcat(msg, yytname[x]);
1768: strcat(msg, "'");
1769: count++;
1770: }
1771: }
1772: yyerror(msg);
1773: free(msg);
1774: }
1775: else
1776: yyerror ("parse error; also virtual memory exceeded");
1777: }
1778: else
1779: #endif /* YYERROR_VERBOSE */
1780: yyerror("parse error");
1781: }
1782:
1783: goto yyerrlab1;
1784: yyerrlab1: /* here on error raised explicitly by an action */
1785:
1786: if (yyerrstatus == 3)
1787: {
1788: /* if just tried and failed to reuse lookahead token after an error, discard it. */
1789:
1790: /* return failure if at end of input */
1791: if (yychar == YYEOF)
1792: YYABORT;
1793:
1794: #if YYDEBUG != 0
1795: if (yydebug)
1796: fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1797: #endif
1798:
1799: yychar = YYEMPTY;
1800: }
1801:
1802: /* Else will try to reuse lookahead token
1803: after shifting the error token. */
1804:
1805: yyerrstatus = 3; /* Each real token shifted decrements this */
1806:
1807: goto yyerrhandle;
1808:
1809: yyerrdefault: /* current state does not do anything special for the error token. */
1810:
1811: #if 0
1812: /* This is wrong; only states that explicitly want error tokens
1813: should shift them. */
1814: yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1815: if (yyn) goto yydefault;
1816: #endif
1817:
1818: yyerrpop: /* pop the current state because it cannot handle the error token */
1819:
1820: if (yyssp == yyss) YYABORT;
1821: yyvsp--;
1822: yystate = *--yyssp;
1823: #ifdef YYLSP_NEEDED
1824: yylsp--;
1825: #endif
1826:
1827: #if YYDEBUG != 0
1828: if (yydebug)
1829: {
1830: short *ssp1 = yyss - 1;
1831: fprintf (stderr, "Error: state stack now");
1832: while (ssp1 != yyssp)
1833: fprintf (stderr, " %d", *++ssp1);
1834: fprintf (stderr, "\n");
1835: }
1836: #endif
1837:
1838: yyerrhandle:
1839:
1840: yyn = yypact[yystate];
1841: if (yyn == YYFLAG)
1842: goto yyerrdefault;
1843:
1844: yyn += YYTERROR;
1845: if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1846: goto yyerrdefault;
1847:
1848: yyn = yytable[yyn];
1849: if (yyn < 0)
1850: {
1851: if (yyn == YYFLAG)
1852: goto yyerrpop;
1853: yyn = -yyn;
1854: goto yyreduce;
1855: }
1856: else if (yyn == 0)
1857: goto yyerrpop;
1858:
1859: if (yyn == YYFINAL)
1860: YYACCEPT;
1861:
1862: #if YYDEBUG != 0
1863: if (yydebug)
1864: fprintf(stderr, "Shifting error token, ");
1865: #endif
1866:
1867: *++yyvsp = yylval;
1868: #ifdef YYLSP_NEEDED
1869: *++yylsp = yylloc;
1870: #endif
1871:
1872: yystate = yyn;
1873: goto yynewstate;
1874:
1875: yyacceptlab:
1876: /* YYACCEPT comes here. */
1877: if (yyfree_stacks)
1878: {
1879: free (yyss);
1880: free (yyvs);
1881: #ifdef YYLSP_NEEDED
1882: free (yyls);
1883: #endif
1884: }
1885: return 0;
1886:
1887: yyabortlab:
1888: /* YYABORT comes here. */
1889: if (yyfree_stacks)
1890: {
1891: free (yyss);
1892: free (yyvs);
1893: #ifdef YYLSP_NEEDED
1894: free (yyls);
1895: #endif
1896: }
1897: return 1;
1898: }
1.84 paf 1899: #line 597 "compile.y"
1.1 parser 1900:
1901: #endif
1902:
1903: /*
1904: 000$111(2222)00
1905: 000$111{3333}00
1906: $,^: push,=0
1907: 1:( { break=pop
1908: 2:( ) pop
1909: 3:{ } pop
1910:
1911: 000^111(2222)4444{33333}4000
1912: $,^: push,=0
1913: 1:( { break=pop
1914: 2:( )=4
1915: 3:{ }=4
1916: 4:[^({]=pop
1917: */
1918:
1.84 paf 1919: inline void ungetc(Parse_control& pc, uint last_line_end_col) {
1920: pc.source--;
1921: if(pc.pos.col==0) {
1922: --pc.pos.line; pc.pos.col=last_line_end_col;
1923: } else
1924: --pc.pos.col;
1925:
1926: }
1927: static int yylex(YYSTYPE *lvalp, void *apc) {
1928: register Parse_control& pc=*static_cast<Parse_control*>(apc);
1929:
1930: #define lexical_brackets_nestage pc.brackets_nestages[pc.ls_sp]
1.1 parser 1931: #define RC {result=c; goto break2; }
1932:
1.84 paf 1933: register int c;
1934: int result;
1.1 parser 1935:
1.84 paf 1936: if(pc.pending_state) {
1937: result=pc.pending_state;
1938: pc.pending_state=0;
1.1 parser 1939: return result;
1940: }
1941:
1.84 paf 1942: const char *begin=pc.source;
1943: Pos begin_pos=pc.pos;
1.1 parser 1944: const char *end;
1945: int skip_analized=0;
1946: while(true) {
1.84 paf 1947: c=*(end=(pc.source++));
1948: // fprintf(stderr, "\nchar: %c %02X; nestage: %d, sp=%d", c, c, lexical_brackets_nestage, pc.sp);
1.1 parser 1949:
1950: if(c=='\n') {
1.84 paf 1951: pc.pos_next_line();
1.1 parser 1952: } else
1.84 paf 1953: pc.pos_next_c(c);
1.1 parser 1954:
1.84 paf 1955: if(c=='@' && pc.pos.col==0+1) {
1956: if(pc.ls==LS_DEF_SPECIAL_BODY) {
1.31 paf 1957: // @SPECIAL
1958: // ...
1959: // @<here =
1.84 paf 1960: pop_LS(pc); // exiting from LS_DEF_SPECIAL_BODY state
1.31 paf 1961: } // continuing checks
1.84 paf 1962: if(pc.ls==LS_USER) {
1963: push_LS(pc, LS_DEF_NAME);
1.20 parser 1964: RC;
1.31 paf 1965: } else // @ in first column inside some code [when could that be?]
1.20 parser 1966: result=BAD_METHOD_DECL_START;
1967: goto break2;
1.75 paf 1968: } else if(c=='^') {
1.84 paf 1969: if(pc.ls==LS_METHOD_AFTER) {
1.75 paf 1970: // handle after-method situation
1.84 paf 1971: pop_LS(pc);
1.75 paf 1972: result=EON;
1973: skip_analized=-1; // return to punctuation afterwards to assure it's literality
1974: goto break2;
1975: }
1.84 paf 1976: switch(pc.ls) {
1.15 parser 1977: case LS_EXPRESSION_VAR_NAME_WITH_COLON:
1978: case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON:
1979: case LS_VAR_NAME_SIMPLE_WITH_COLON:
1980: case LS_VAR_NAME_SIMPLE_WITHOUT_COLON:
1981: case LS_VAR_NAME_CURLY:
1982: case LS_METHOD_NAME:
1.66 paf 1983: case LS_USER_COMMENT:
1.15 parser 1984: case LS_DEF_COMMENT:
1985: // no literals in names, please
1986: break;
1987: default:
1.84 paf 1988: switch(*pc.source) {
1.10 parser 1989: // ^escaping some punctuators
1.1 parser 1990: case '^': case '$': case ';':
1991: case '(': case ')':
1992: case '[': case ']':
1993: case '{': case '}':
1.23 parser 1994: case '"': case ':':
1.1 parser 1995: if(end!=begin) {
1.84 paf 1996: if(!pc.string_start)
1997: pc.string_start=begin_pos;
1.1 parser 1998: // append piece till ^
1.84 paf 1999: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 2000: }
2001: // reset piece 'begin' position & line
1.84 paf 2002: begin=pc.source; // ->punctuation
2003: begin_pos=pc.pos;
1.75 paf 2004: // skip over _ after ^
1.84 paf 2005: pc.source++; pc.pos.col++;
1.75 paf 2006: // skip analysis = forced literal
2007: continue;
1.1 parser 2008:
2009: // converting ^#HH into char(hex(HH))
2010: case '#':
2011: if(end!=begin) {
1.84 paf 2012: if(!pc.string_start)
2013: pc.string_start=begin_pos;
1.1 parser 2014: // append piece till ^
1.84 paf 2015: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 2016: }
2017: // #HH ?
1.84 paf 2018: if(pc.source[0]=='#' && pc.source[1] && pc.source[2]) {
2019: char c=
2020: hex_value[(unsigned char)pc.source[1]]*0x10+
2021: hex_value[(unsigned char)pc.source[2]];
2022: if(c==0) {
1.1 parser 2023: result=BAD_HEX_LITERAL;
2024: goto break2; // wrong hex value[no ^#00 chars allowed]: bail out
2025: }
2026: // append char(hex(HH))
1.84 paf 2027: pc.string.append(c);
1.1 parser 2028: // skip over ^#HH
1.84 paf 2029: pc.source+=3;
2030: pc.pos.col+=3;
1.1 parser 2031: // reset piece 'begin' position & line
1.84 paf 2032: begin=pc.source; // ->after ^#HH
2033: begin_pos=pc.pos;
1.75 paf 2034: // skip analysis = forced literal
1.1 parser 2035: continue;
2036: }
2037: break;
2038: }
1.15 parser 2039: break;
1.75 paf 2040: }
1.15 parser 2041: }
1.1 parser 2042: // #comment start skipping
1.84 paf 2043: if(c=='#' && pc.pos.col==1) {
1.1 parser 2044: if(end!=begin) {
1.84 paf 2045: if(!pc.string_start)
2046: pc.string_start=begin_pos;
1.1 parser 2047: // append piece till #
1.84 paf 2048: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 2049: }
2050: // fall into COMMENT lexical state [wait for \n]
1.84 paf 2051: push_LS(pc, LS_USER_COMMENT);
1.31 paf 2052: continue;
1.1 parser 2053: }
1.84 paf 2054: switch(pc.ls) {
1.1 parser 2055:
2056: // USER'S = NOT OURS
2057: case LS_USER:
1.84 paf 2058: case LS_NAME_SQUARE_PART: // name.[here].xxx
2059: if(pc.trim_bof)
1.1 parser 2060: switch(c) {
2061: case '\n': case ' ': case '\t':
1.84 paf 2062: begin=pc.source;
2063: begin_pos=pc.pos;
1.1 parser 2064: continue; // skip it
2065: default:
1.84 paf 2066: pc.trim_bof=false;
1.1 parser 2067: }
2068: switch(c) {
2069: case '$':
1.84 paf 2070: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 2071: RC;
2072: case '^':
1.84 paf 2073: push_LS(pc, LS_METHOD_NAME);
1.1 parser 2074: RC;
1.11 parser 2075: case ']':
1.84 paf 2076: if(pc.ls==LS_NAME_SQUARE_PART)
1.11 parser 2077: if(--lexical_brackets_nestage==0) {// $name.[co<]?>de<]?>
1.84 paf 2078: pop_LS(pc); // $name.[co<]>de<]!>
1.11 parser 2079: RC;
2080: }
1.3 parser 2081: break;
1.11 parser 2082: case '[': // $name.[co<[>de]
1.84 paf 2083: if(pc.ls==LS_NAME_SQUARE_PART)
1.11 parser 2084: lexical_brackets_nestage++;
1.4 parser 2085: break;
1.1 parser 2086: }
2087: break;
2088:
2089: // #COMMENT
1.66 paf 2090: case LS_USER_COMMENT:
1.1 parser 2091: if(c=='\n') {
2092: // skip comment
1.84 paf 2093: begin=pc.source;
2094: begin_pos=pc.pos;
1.1 parser 2095:
1.84 paf 2096: pop_LS(pc);
1.1 parser 2097: continue;
2098: }
2099: break;
2100:
2101: // STRING IN EXPRESSION
2102: case LS_EXPRESSION_STRING_QUOTED:
2103: case LS_EXPRESSION_STRING_APOSTROFED:
2104: switch(c) {
2105: case '"':
2106: case '\'':
2107: if(
1.84 paf 2108: pc.ls == LS_EXPRESSION_STRING_QUOTED && c=='"' ||
2109: pc.ls == LS_EXPRESSION_STRING_APOSTROFED && c=='\'') {
2110: pop_LS(pc); //"abc". | 'abc'.
1.1 parser 2111: RC;
2112: }
2113: break;
2114: case '$':
1.84 paf 2115: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 2116: RC;
2117: case '^':
1.84 paf 2118: push_LS(pc, LS_METHOD_NAME);
1.1 parser 2119: RC;
2120: }
2121: break;
2122:
2123: // METHOD DEFINITION
2124: case LS_DEF_NAME:
2125: switch(c) {
2126: case '[':
1.84 paf 2127: pc.ls=LS_DEF_PARAMS;
1.1 parser 2128: RC;
2129: case '\n':
1.84 paf 2130: pc.ls=LS_DEF_SPECIAL_BODY;
1.1 parser 2131: RC;
2132: }
2133: break;
2134:
2135: case LS_DEF_PARAMS:
2136: switch(c) {
1.64 paf 2137: case '$': // common error
1.65 paf 2138: result=BAD_METHOD_PARAMETER_NAME_CHARACTER;
2139: goto break2;
1.1 parser 2140: case ';':
2141: RC;
2142: case ']':
1.84 paf 2143: pc.ls=*pc.source=='['?LS_DEF_LOCALS:LS_DEF_COMMENT;
1.1 parser 2144: RC;
2145: case '\n': // wrong. bailing out
1.84 paf 2146: pop_LS(pc);
1.1 parser 2147: RC;
2148: }
2149: break;
2150:
2151: case LS_DEF_LOCALS:
2152: switch(c) {
2153: case '[':
2154: case ';':
2155: RC;
2156: case ']':
1.84 paf 2157: pc.ls=LS_DEF_COMMENT;
1.1 parser 2158: RC;
2159: case '\n': // wrong. bailing out
1.84 paf 2160: pop_LS(pc);
1.1 parser 2161: RC;
2162: }
2163: break;
2164:
2165: case LS_DEF_COMMENT:
2166: if(c=='\n') {
1.84 paf 2167: pop_LS(pc);
1.1 parser 2168: RC;
2169: }
2170: break;
2171:
2172: case LS_DEF_SPECIAL_BODY:
1.31 paf 2173: if(c=='\n')
1.1 parser 2174: RC;
2175: break;
2176:
2177: // (EXPRESSION)
2178: case LS_VAR_ROUND:
2179: case LS_METHOD_ROUND:
2180: switch(c) {
2181: case ')':
2182: if(--lexical_brackets_nestage==0)
1.84 paf 2183: if(pc.ls==LS_METHOD_ROUND) // method round param ended
2184: pc.ls=LS_METHOD_AFTER; // look for method end
2185: else // pc.ls==LS_VAR_ROUND // variable constructor ended
2186: pop_LS(pc); // return to normal life
1.1 parser 2187: RC;
1.66 paf 2188: case '#': // comment start skipping
2189: if(end!=begin) {
1.84 paf 2190: if(!pc.string_start)
2191: pc.string_start=begin_pos;
1.66 paf 2192: // append piece till #
1.84 paf 2193: pc.string.append_strdup_know_length(begin, end-begin);
1.66 paf 2194: }
2195: // fall into COMMENT lexical state [wait for \n]
1.84 paf 2196: push_LS(pc, LS_EXPRESSION_COMMENT);
1.66 paf 2197: lexical_brackets_nestage=1;
2198: continue;
1.1 parser 2199: case '$':
1.84 paf 2200: push_LS(pc, LS_EXPRESSION_VAR_NAME_WITH_COLON);
1.1 parser 2201: RC;
2202: case '^':
1.84 paf 2203: push_LS(pc, LS_METHOD_NAME);
1.1 parser 2204: RC;
2205: case '(':
2206: lexical_brackets_nestage++;
2207: RC;
2208: case '-':
1.84 paf 2209: switch(*pc.source) {
1.1 parser 2210: case 'f': // -f
2211: skip_analized=1;
2212: result=FEXISTS;
2213: goto break2;
2214: case 'd': // -d
2215: skip_analized=1;
2216: result=DEXISTS;
2217: goto break2;
1.63 paf 2218: default: // minus
1.1 parser 2219: result=c;
2220: goto break2;
2221: }
2222: goto break2;
1.25 paf 2223: case '+': case '*': case '/': case '%': case '\\':
1.1 parser 2224: case '~':
2225: case ';':
2226: RC;
1.65 paf 2227: case '&': case '|':
1.84 paf 2228: if(*pc.source==c) { // && ||
1.65 paf 2229: result=c=='&'?LAND:LOR;
1.1 parser 2230: skip_analized=1;
2231: } else
2232: result=c;
2233: goto break2;
1.65 paf 2234: case '!':
1.84 paf 2235: switch(pc.source[0]) {
1.65 paf 2236: case '|': // !| !||
2237: skip_analized=1;
1.84 paf 2238: if(pc.source[1]=='|') {
1.65 paf 2239: skip_analized++;
2240: result=LXOR;
2241: } else
2242: result=NXOR;
2243: goto break2;
2244: case '=': // !=
2245: skip_analized=1;
2246: result=NNE;
2247: goto break2;
2248: }
2249: RC;
1.67 paf 2250:
2251: case '<': // <<, <=, <
1.84 paf 2252: switch(*pc.source) {
1.67 paf 2253: case '<': // <[<]
2254: skip_analized=1; result=NSL; break;
2255: case '=': // <[=]
2256: skip_analized=1; result=NLE; break;
2257: default: // <[]
2258: result=c; break;
2259: }
2260: goto break2;
2261: case '>': // >>, >=, >
1.84 paf 2262: switch(*pc.source) {
1.67 paf 2263: case '>': // >[>]
2264: skip_analized=1; result=NSR; break;
2265: case '=': // >[=]
2266: skip_analized=1; result=NGE; break;
2267: default: // >[]
2268: result=c; break;
2269: }
2270: goto break2;
2271: case '=': // ==
1.84 paf 2272: switch(*pc.source) {
1.67 paf 2273: case '=': // =[=]
2274: skip_analized=1; result=NEQ; break;
2275: default: // =[]
2276: result=c; break; // not used now
2277: }
1.1 parser 2278: goto break2;
1.67 paf 2279:
1.1 parser 2280: case '"':
1.84 paf 2281: push_LS(pc, LS_EXPRESSION_STRING_QUOTED);
1.1 parser 2282: RC;
2283: case '\'':
1.84 paf 2284: push_LS(pc, LS_EXPRESSION_STRING_APOSTROFED);
1.1 parser 2285: RC;
2286: case 'l': case 'g': case 'e': case 'n':
2287: if(end==begin) // right after whitespace
1.84 paf 2288: if(isspace(pc.source[1])) {
2289: switch(*pc.source) {
1.1 parser 2290: // case '?': // ok [and bad cases, yacc would bark at them]
2291: case 't': // lt gt [et nt]
2292: result=c=='l'?SLT:c=='g'?SGT:BAD_STRING_COMPARISON_OPERATOR;
2293: skip_analized=1;
2294: goto break2;
2295: case 'e': // le ge ne [ee]
2296: result=c=='l'?SLE:c=='g'?SGE:c=='n'?SNE:BAD_STRING_COMPARISON_OPERATOR;
2297: skip_analized=1;
2298: goto break2;
2299: case 'q': // eq [lq gq nq]
2300: result=c=='e'?SEQ:BAD_STRING_COMPARISON_OPERATOR;
2301: skip_analized=1;
2302: goto break2;
2303: }
2304: }
2305: break;
2306: case 'i':
2307: if(end==begin) // right after whitespace
1.84 paf 2308: if(isspace(pc.source[1])) {
2309: switch(pc.source[0]) {
1.1 parser 2310: case 'n': // in
2311: skip_analized=1;
2312: result=IN;
2313: goto break2;
2314: case 's': // is
2315: skip_analized=1;
2316: result=IS;
2317: goto break2;
2318: }
2319: }
2320: break;
2321: case 'd':
2322: if(end==begin) // right after whitespace
1.84 paf 2323: if(pc.source[0]=='e' && pc.source[1]=='f') { // def
1.1 parser 2324: skip_analized=2;
2325: result=DEF;
2326: goto break2;
2327: }
2328: break;
2329: case ' ': case '\t': case '\n':
2330: if(end!=begin) { // there were a string after previous operator?
2331: result=0; // return that string
2332: goto break2;
2333: }
2334: // that's a leading|traling space or after-operator-space
2335: // ignoring it
2336: // reset piece 'begin' position & line
1.84 paf 2337: begin=pc.source; // after whitespace char
2338: begin_pos=pc.pos;
1.1 parser 2339: continue;
2340: }
2341: break;
1.66 paf 2342: case LS_EXPRESSION_COMMENT:
2343: if(c=='(')
2344: lexical_brackets_nestage++;
2345:
1.84 paf 2346: switch(*pc.source) {
1.66 paf 2347: case '\n': case ')':
1.84 paf 2348: if(*pc.source==')')
1.66 paf 2349: if(--lexical_brackets_nestage!=0)
2350: continue;
2351:
2352: // skip comment
1.84 paf 2353: begin=pc.source;
2354: begin_pos=pc.pos;
1.66 paf 2355:
1.84 paf 2356: pop_LS(pc);
1.66 paf 2357: continue;
2358: }
2359: break;
1.1 parser 2360:
2361: // VARIABLE GET/PUT/WITH
1.11 parser 2362: case LS_VAR_NAME_SIMPLE_WITH_COLON:
2363: case LS_VAR_NAME_SIMPLE_WITHOUT_COLON:
2364: case LS_EXPRESSION_VAR_NAME_WITH_COLON:
2365: case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON:
2366: if(
1.84 paf 2367: pc.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON ||
2368: pc.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) {
1.41 paf 2369: // name in expr ends also before
1.1 parser 2370: switch(c) {
1.41 paf 2371: // expression minus
1.1 parser 2372: case '-':
1.41 paf 2373: // expression integer division
2374: case '\\':
1.84 paf 2375: pop_LS(pc);
2376: pc.ungetc();
1.1 parser 2377: result=EON;
2378: goto break2;
2379: }
2380: }
1.11 parser 2381: if(
1.84 paf 2382: pc.ls==LS_VAR_NAME_SIMPLE_WITHOUT_COLON ||
2383: pc.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) {
1.1 parser 2384: // name already has ':', stop before next
2385: switch(c) {
2386: case ':':
1.84 paf 2387: pop_LS(pc);
2388: pc.ungetc();
1.1 parser 2389: result=EON;
2390: goto break2;
2391: }
2392: }
2393: switch(c) {
2394: case 0:
2395: case ' ': case '\t': case '\n':
2396: case ';':
2397: case ']': case '}': case ')':
2398: case '"': case '\'':
2399: case '<': case '>': // these stand for HTML brackets AND expression binary ops
2400: case '+': case '*': case '/': case '%':
2401: case '&': case '|':
2402: case '=': case '!':
2403: // common delimiters
1.62 paf 2404: case ',': case '?': case '#':
1.1 parser 2405: // before call
2406: case '^':
1.84 paf 2407: pop_LS(pc);
2408: pc.ungetc();
1.1 parser 2409: result=EON;
2410: goto break2;
2411: case '[':
1.5 parser 2412: // $name.<[>code]
1.84 paf 2413: if(pc.pos.col>1/*not first column*/ && (
1.6 parser 2414: end[-1]=='$'/*was start of get*/ ||
2415: end[-1]==':'/*was class name delim */ ||
2416: end[-1]=='.'/*was name delim */
1.5 parser 2417: )) {
1.84 paf 2418: push_LS(pc, LS_NAME_SQUARE_PART);
1.5 parser 2419: lexical_brackets_nestage=1;
2420: RC;
2421: }
1.84 paf 2422: pc.ls=LS_VAR_SQUARE;
1.1 parser 2423: lexical_brackets_nestage=1;
2424: RC;
2425: case '{':
2426: if(begin==end) { // ${name}, no need of EON, switching LS
1.84 paf 2427: pc.ls=LS_VAR_NAME_CURLY;
1.1 parser 2428: } else {
1.84 paf 2429: pc.ls=LS_VAR_CURLY;
1.1 parser 2430: lexical_brackets_nestage=1;
2431: }
2432:
2433: RC;
2434: case '(':
1.84 paf 2435: pc.ls=LS_VAR_ROUND;
1.1 parser 2436: lexical_brackets_nestage=1;
2437: RC;
2438: case '.': // name part delim
2439: case '$': // name part subvar
1.3 parser 2440: case ':': // class<:>name
1.11 parser 2441: // go to _WITHOUT_COLON state variant...
1.84 paf 2442: if(pc.ls==LS_VAR_NAME_SIMPLE_WITH_COLON)
2443: pc.ls=LS_VAR_NAME_SIMPLE_WITHOUT_COLON;
2444: else if(pc.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON)
2445: pc.ls=LS_EXPRESSION_VAR_NAME_WITHOUT_COLON;
1.11 parser 2446: // ...stop before next ':'
1.1 parser 2447: RC;
2448: }
2449: break;
2450:
2451: case LS_VAR_NAME_CURLY:
2452: switch(c) {
1.5 parser 2453: case '[':
1.11 parser 2454: // ${name.<[>code]}
1.84 paf 2455: push_LS(pc, LS_NAME_SQUARE_PART);
1.3 parser 2456: lexical_brackets_nestage=1;
2457: RC;
1.1 parser 2458: case '}': // ${name} finished, restoring LS
1.84 paf 2459: pop_LS(pc);
1.1 parser 2460: RC;
2461: case '.': // name part delim
2462: case '$': // name part subvar
2463: case ':': // ':name' or 'class:name'
2464: RC;
2465: }
2466: break;
2467:
2468: case LS_VAR_SQUARE:
2469: switch(c) {
2470: case '$':
1.84 paf 2471: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 2472: RC;
2473: case '^':
1.84 paf 2474: push_LS(pc, LS_METHOD_NAME);
1.1 parser 2475: RC;
2476: case ']':
2477: if(--lexical_brackets_nestage==0) {
1.84 paf 2478: pop_LS(pc);
1.1 parser 2479: RC;
2480: }
2481: break;
2482: case ';': // operator_or_fmt;value delim
2483: RC;
2484: case '[':
2485: lexical_brackets_nestage++;
2486: break;
2487: }
2488: break;
2489:
2490: case LS_VAR_CURLY:
2491: switch(c) {
2492: case '$':
1.84 paf 2493: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 2494: RC;
2495: case '^':
1.84 paf 2496: push_LS(pc, LS_METHOD_NAME);
1.1 parser 2497: RC;
2498: case '}':
2499: if(--lexical_brackets_nestage==0) {
1.84 paf 2500: pop_LS(pc);
1.1 parser 2501: RC;
2502: }
2503: break;
2504: case '{':
2505: lexical_brackets_nestage++;
2506: break;
2507: }
2508: break;
2509:
2510: // METHOD CALL
2511: case LS_METHOD_NAME:
2512: switch(c) {
2513: case '[':
1.11 parser 2514: // ^name.<[>code].xxx
1.84 paf 2515: if(pc.pos.col>1/*not first column*/ && (
1.6 parser 2516: end[-1]=='^'/*was start of call*/ || // never, ^[ is literal...
2517: end[-1]==':'/*was class name delim */ ||
2518: end[-1]=='.'/*was name delim */
1.5 parser 2519: )) {
1.84 paf 2520: push_LS(pc, LS_NAME_SQUARE_PART);
1.5 parser 2521: lexical_brackets_nestage=1;
2522: RC;
2523: }
1.84 paf 2524: pc.ls=LS_METHOD_SQUARE;
1.1 parser 2525: lexical_brackets_nestage=1;
2526: RC;
2527: case '{':
1.84 paf 2528: pc.ls=LS_METHOD_CURLY;
1.1 parser 2529: lexical_brackets_nestage=1;
2530: RC;
2531: case '(':
1.84 paf 2532: pc.ls=LS_METHOD_ROUND;
1.1 parser 2533: lexical_brackets_nestage=1;
2534: RC;
2535: case '.': // name part delim
2536: case '$': // name part subvar
2537: case ':': // ':name' or 'class:name'
1.19 parser 2538: case '^': // ^abc^xxx wrong. bailing out
2539: case ']': case '}': case ')': // ^abc]}) wrong. bailing out
1.1 parser 2540: RC;
2541: }
2542: break;
2543:
2544: case LS_METHOD_SQUARE:
2545: switch(c) {
2546: case '$':
1.84 paf 2547: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 2548: RC;
2549: case '^':
1.84 paf 2550: push_LS(pc, LS_METHOD_NAME);
1.1 parser 2551: RC;
2552: case ';': // param delim
2553: RC;
2554: case ']':
2555: if(--lexical_brackets_nestage==0) {
1.84 paf 2556: pc.ls=LS_METHOD_AFTER;
1.1 parser 2557: RC;
2558: }
2559: break;
2560: case '[':
2561: lexical_brackets_nestage++;
2562: break;
2563: }
2564: break;
2565:
2566: case LS_METHOD_CURLY:
2567: switch(c) {
2568: case '$':
1.84 paf 2569: push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON);
1.1 parser 2570: RC;
2571: case '^':
1.84 paf 2572: push_LS(pc, LS_METHOD_NAME);
1.1 parser 2573: RC;
2574: case ';': // param delim
2575: RC;
2576: case '}':
2577: if(--lexical_brackets_nestage==0) {
1.84 paf 2578: pc.ls=LS_METHOD_AFTER;
1.1 parser 2579: RC;
2580: }
2581: break;
2582: case '{':
2583: lexical_brackets_nestage++;
2584: break;
2585: }
2586: break;
2587:
2588: case LS_METHOD_AFTER:
2589: if(c=='[') {/* ][ }[ )[ */
1.84 paf 2590: pc.ls=LS_METHOD_SQUARE;
1.1 parser 2591: lexical_brackets_nestage=1;
2592: RC;
2593: }
2594: if(c=='{') {/* ]{ }{ ){ */
1.84 paf 2595: pc.ls=LS_METHOD_CURLY;
1.1 parser 2596: lexical_brackets_nestage=1;
2597: RC;
2598: }
2599: if(c=='(') {/* ]( }( )( */
1.84 paf 2600: pc.ls=LS_METHOD_ROUND;
1.1 parser 2601: lexical_brackets_nestage=1;
2602: RC;
2603: }
1.84 paf 2604: pop_LS(pc);
2605: pc.ungetc();
1.1 parser 2606: result=EON;
2607: goto break2;
2608: }
2609: if(c==0) {
2610: result=-1;
2611: break;
2612: }
2613: }
2614:
2615: break2:
2616: if(end!=begin) { // there is last piece?
2617: if((c=='@' || c==0) && end[-1]=='\n') { // we are before LS_DEF_NAME or EOF?
2618: // strip last \n
2619: end--;
2620: if(end!=begin && end[-1]=='\n') // allow one empty line before LS_DEF_NAME
2621: end--;
2622: }
1.84 paf 2623: if(end!=begin && pc.ls!=LS_USER_COMMENT) { // last piece still alive and not comment?
2624: if(!pc.string_start)
2625: pc.string_start=begin_pos;
1.1 parser 2626: // append it
1.84 paf 2627: pc.string.append_strdup_know_length(begin, end-begin);
1.1 parser 2628: }
2629: }
1.84 paf 2630: if(!pc.string.is_empty()) { // something accumulated?
2631: // create STRING value: array of OP_VALUE+origin+vstring
2632: *lvalp=VL(
2633: new VString(*new String(pc.string, String::L_CLEAN)),
2634: pc.file_no, pc.string_start.line, pc.string_start.col);
1.1 parser 2635: // new pieces storage
1.84 paf 2636: pc.string.clear();
2637: pc.string_start.clear();
1.1 parser 2638: // make current result be pending for next call, return STRING for now
1.84 paf 2639: pc.pending_state=result; result=STRING;
1.1 parser 2640: }
2641: if(skip_analized) {
1.84 paf 2642: pc.source+=skip_analized; pc.pos.col+=skip_analized;
1.1 parser 2643: }
2644: return result;
2645: }
2646:
1.84 paf 2647: static int real_yyerror(Parse_control *pc, char *s) { // Called by yyparse on error
1.10 parser 2648: strncpy(PC.error, s, MAX_STRING);
1.1 parser 2649: return 1;
2650: }
2651:
2652: static void yyprint(FILE *file, int type, YYSTYPE value) {
2653: if(type==STRING)
1.84 paf 2654: fprintf(file, " \"%s\"", LA2S(*value)->cstr());
1.1 parser 2655: }
E-mail: