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