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