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