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