--- parser3/src/main/compile.tab.C 2003/04/02 16:05:19 1.81.2.13.2.21 +++ parser3/src/main/compile.tab.C 2003/08/19 09:07:02 1.87 @@ -43,7 +43,7 @@ Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.tab.C,v 1.81.2.13.2.21 2003/04/02 16:05:19 paf Exp $ + $Id: compile.tab.C,v 1.87 2003/08/19 09:07:02 paf Exp $ */ /** @@ -65,6 +65,8 @@ #define yyerror(msg) real_yyerror((Parse_control *)pc, msg) #define YYPRINT(file, type, value) yyprint(file, type, value) +// includes + #include "compile_tools.h" #include "pa_value.h" #include "pa_request.h" @@ -74,11 +76,15 @@ #include "pa_vvoid.h" #include "pa_vmethod_frame.h" +// defines + #define USE_CONTROL_METHOD_NAME "USE" -static int real_yyerror(Parse_control *pc, char *s); -static void yyprint(FILE *file, int type, YYSTYPE value); -static int yylex(YYSTYPE *lvalp, void *pc); +// forwards + +static int real_yyerror(Parse_control* pc, char* s); +static void yyprint(FILE* file, int type, YYSTYPE value); +static int yylex(YYSTYPE* lvalp, void* pc); // local convinient inplace typecast & var @@ -210,22 +216,22 @@ static const short yyrhs[] = { 62, #if YYDEBUG != 0 static const short yyrline[] = { 0, - 115, 123, 125, 125, 126, 128, 128, 130, 202, 202, - 203, 203, 204, 205, 205, 207, 236, 236, 237, 238, - 238, 239, 239, 241, 241, 245, 245, 247, 247, 248, - 248, 249, 249, 249, 253, 260, 261, 261, 262, 263, - 265, 266, 288, 289, 289, 293, 297, 299, 300, 301, - 318, 323, 325, 327, 328, 330, 336, 344, 350, 352, - 353, 355, 361, 362, 362, 366, 372, 375, 378, 391, - 393, 393, 394, 396, 397, 399, 400, 401, 402, 404, - 406, 408, 410, 412, 414, 418, 422, 426, 428, 429, - 431, 440, 440, 442, 442, 443, 444, 452, 457, 459, - 461, 462, 463, 465, 469, 478, 484, 489, 489, 490, - 495, 497, 499, 511, 523, 528, 530, 531, 532, 533, - 534, 536, 537, 538, 539, 540, 541, 542, 543, 545, - 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, - 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, - 566, 567, 568, 569, 570, 571, 574, 583, 588, 589 + 121, 129, 131, 131, 132, 134, 134, 136, 208, 208, + 209, 209, 210, 211, 211, 213, 242, 242, 243, 244, + 244, 245, 245, 247, 247, 251, 251, 253, 253, 254, + 254, 255, 255, 255, 259, 266, 267, 267, 268, 269, + 271, 272, 294, 295, 295, 299, 303, 305, 306, 307, + 324, 329, 331, 333, 334, 336, 342, 350, 356, 358, + 359, 361, 367, 368, 368, 372, 378, 381, 384, 397, + 399, 399, 400, 402, 403, 405, 406, 407, 408, 410, + 412, 414, 416, 418, 420, 424, 428, 432, 434, 435, + 437, 446, 446, 448, 448, 449, 450, 458, 463, 465, + 467, 468, 469, 471, 475, 484, 490, 495, 495, 496, + 501, 503, 505, 517, 529, 534, 536, 537, 538, 539, + 540, 542, 543, 544, 545, 546, 547, 548, 549, 551, + 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, + 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, + 572, 573, 574, 575, 576, 577, 580, 589, 594, 595 }; #endif @@ -765,14 +771,14 @@ yyparse(YYPARSE_PARAM_ARG) #ifdef YYPURE int yychar; - YYSTYPE yylval; + YYSTYPE yylval=0; /*paf:calm down, vc7 warning level 4*/ int yynerrs; #ifdef YYLSP_NEEDED YYLTYPE yylloc; #endif #endif - YYSTYPE yyval; /* the variable used to return */ + YYSTYPE yyval=0; /*paf:calm down, vc7 warning level 4*/ /* the variable used to return */ /* semantic values from the action */ /* routines */ @@ -1032,21 +1038,21 @@ yyreduce: switch (yyn) { case 1: -#line 116 "compile.y" +#line 122 "compile.y" { - Method& method=*new Method(/*main_method_name, */Method::CT_ANY, + Method& method=*new Method(Method::CT_ANY, 0, 0, /*min, max numbered_params_count*/ 0/*param_names*/, 0/*local_names*/, yyvsp[0]/*parser_code*/, 0/*native_code*/); - PC.cclass->add_method(main_method_name, method); + PC.cclass->add_method(PC.alias_method(main_method_name), method); ; break;} case 8: -#line 131 "compile.y" +#line 137 "compile.y" { const String& command=*LA2S(*yyvsp[-2]); YYSTYPE strings_code=yyvsp[0]; - if(strings_code->count()<1*2) { + if(strings_code->count()<1*OPERATIONS_PER_OPVALUE) { strcpy(PC.error, "@"); strcat(PC.error, command.cstr()); strcat(PC.error, " is empty"); @@ -1059,7 +1065,7 @@ case 8: strcat(PC.error, "'"); YYERROR; } - if(strings_code->count()==1*2) { + if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) { // new class' name const String& name=*LA2S(*strings_code); // creating the class @@ -1069,11 +1075,11 @@ case 8: // append to request's classes PC.request.classes().put(name, cclass); } else { - strcpy(PC.error, "@"CLASS_NAME" must contain sole name"); + strcpy(PC.error, "@"CLASS_NAME" must contain only one line with class name (contains more then one)"); YYERROR; } } else if(command==USE_CONTROL_METHOD_NAME) { - for(size_t i=0; icount(); i+=2) + for(size_t i=0; icount(); i+=OPERATIONS_PER_OPVALUE) PC.request.use_file(PC.request.main_class, *LA2S(*strings_code, i)); } else if(command==BASE_NAME) { if(PC.cclass->base_class()) { // already changed from default? @@ -1082,7 +1088,7 @@ case 8: strcat(PC.error, "'"); YYERROR; } - if(strings_code->count()==1*2) { + if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) { const String& base_name=*LA2S(*strings_code); if(Value* base_class_value=PC.request.classes().get(base_name)) { // @CLASS == @BASE sanity check @@ -1116,11 +1122,11 @@ case 8: ; break;} case 12: -#line 203 "compile.y" +#line 209 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; break;} case 16: -#line 208 "compile.y" +#line 214 "compile.y" { const String& name=*LA2S(*yyvsp[-5]); @@ -1128,7 +1134,7 @@ case 16: ArrayString* params_names=0; if(int size=params_names_code->count()) { params_names=new ArrayString; - for(int i=0; icount()) { locals_names=new ArrayString; - for(int i=0; iadd_method(name, method); + PC.cclass->add_method(PC.alias_method(name), method); ; break;} case 19: -#line 237 "compile.y" +#line 243 "compile.y" {yyval=yyvsp[-1]; break;} case 23: -#line 239 "compile.y" +#line 245 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; break;} case 29: -#line 247 "compile.y" +#line 253 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; break;} case 35: -#line 253 "compile.y" +#line 259 "compile.y" { yyval=yyvsp[0]; /* stack: resulting value */ changetail_or_append(*yyval, @@ -1172,66 +1178,66 @@ case 35: ; break;} case 36: -#line 260 "compile.y" +#line 266 "compile.y" { yyval=yyvsp[0] ; break;} case 39: -#line 262 "compile.y" +#line 268 "compile.y" { yyval=yyvsp[-1] ; break;} case 42: -#line 266 "compile.y" +#line 272 "compile.y" { yyval=N(); ArrayOperation* diving_code=yyvsp[0]; const String* first_name=LA2S(*diving_code); // self.xxx... -> xxx... - // OP_VALUE+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+... + // OP_VALUE+origin+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+... if(first_name && *first_name==SELF_ELEMENT_NAME) { O(*yyval, OP_WITH_SELF); /* stack: starting context */ P(*yyval, *diving_code, /* skip over... */ - diving_code->count()>=3?3/*OP_VALUE+string+OP_GET_ELEMENTx*/:2/*OP_+string*/); + diving_code->count()>=4?4/*OP_VALUE+origin+string+OP_GET_ELEMENTx*/:3/*OP_+origin+string*/); } else { O(*yyval, OP_WITH_READ); /* stack: starting context */ // ^if ELEMENT -> ^if ELEMENT_OR_OPERATOR - // OP_VALUE+string+OP_GET_ELEMENT. -> OP_VALUE+string+OP_GET_ELEMENT_OR_OPERATOR. - if(PC.in_call_value && diving_code->count()==3) - diving_code->put(2, OP_GET_ELEMENT_OR_OPERATOR); + // OP_VALUE+origin+string+OP_GET_ELEMENT. -> OP_VALUE+origin+string+OP_GET_ELEMENT_OR_OPERATOR. + if(PC.in_call_value && diving_code->count()==4) + diving_code->put(4-1, OP_GET_ELEMENT_OR_OPERATOR); P(*yyval, *diving_code); } /* diving code; stack: current context */ ; break;} case 43: -#line 288 "compile.y" +#line 294 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; break;} case 45: -#line 289 "compile.y" +#line 295 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; break;} case 46: -#line 293 "compile.y" +#line 299 "compile.y" { yyval=yyvsp[-1]; /* stack: context,name */ P(*yyval, *yyvsp[0]); /* stack: context,name,constructor_value */ ; break;} case 50: -#line 301 "compile.y" +#line 307 "compile.y" { yyval=N(); ArrayOperation* diving_code=yyvsp[0]; const String* first_name=LA2S(*diving_code); // $self.xxx... -> $xxx... - // OP_VALUE+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+... + // OP_VALUE+origin+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+... if(first_name && *first_name==SELF_ELEMENT_NAME) { O(*yyval, OP_WITH_SELF); /* stack: starting context */ P(*yyval, *diving_code, /* skip over... */ - diving_code->count()>=3?3/*OP_VALUE+string+OP_GET_ELEMENTx*/:2/*OP_+string*/); + diving_code->count()>=4?4/*OP_VALUE+origin+string+OP_GET_ELEMENTx*/:3/*OP_+origin+string*/); } else { O(*yyval, OP_WITH_ROOT); /* stack: starting context */ P(*yyval, *diving_code); @@ -1240,7 +1246,7 @@ case 50: ; break;} case 51: -#line 318 "compile.y" +#line 324 "compile.y" { yyval=N(); O(*yyval, OP_WITH_WRITE); /* stack: starting context */ @@ -1248,11 +1254,11 @@ case 51: ; break;} case 52: -#line 323 "compile.y" +#line 329 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; break;} case 56: -#line 330 "compile.y" +#line 336 "compile.y" { // stack: context, name yyval=yyvsp[-1]; // stack: context, name, value @@ -1260,7 +1266,7 @@ case 56: ; break;} case 57: -#line 336 "compile.y" +#line 342 "compile.y" { yyval=N(); O(*yyval, OP_PREPARE_TO_EXPRESSION); @@ -1270,7 +1276,7 @@ case 57: ; break;} case 58: -#line 344 "compile.y" +#line 350 "compile.y" { // stack: context, name yyval=N(); @@ -1278,7 +1284,7 @@ case 58: ; break;} case 62: -#line 355 "compile.y" +#line 361 "compile.y" { yyval=N(); OA(*yyval, OP_OBJECT_POOL, yyvsp[0]); /* stack: empty write context */ @@ -1287,11 +1293,11 @@ case 62: ; break;} case 65: -#line 362 "compile.y" +#line 368 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; break;} case 66: -#line 366 "compile.y" +#line 372 "compile.y" { yyval=yyvsp[0]; /* stack: value */ changetail_or_append(*yyval, @@ -1300,25 +1306,25 @@ case 66: ; break;} case 67: -#line 372 "compile.y" +#line 378 "compile.y" { PC.in_call_value=true; ; break;} case 68: -#line 375 "compile.y" +#line 381 "compile.y" { PC.in_call_value=false; ; break;} case 69: -#line 378 "compile.y" +#line 384 "compile.y" { /* ^field.$method{vasya} */ yyval=yyvsp[-3]; /* with_xxx,diving code; stack: context,method_junction */ YYSTYPE params_code=yyvsp[-1]; - if(params_code->count()==3) { // probably [] case. [OP_VALUE + Void + STORE_PARAM] - if(Value* value=LA2V(*params_code)) // it is OP_VALUE + value? + if(params_code->count()==4) { // probably [] case. [OP_VALUE+origin+Void+STORE_PARAM] + if(Value* value=LA2V(*params_code)) // it is OP_VALUE+origin+value? if(!value->is_defined()) // value is VVoid? params_code=0; // ^zzz[] case. don't append lone empty param. } @@ -1327,56 +1333,56 @@ case 69: ; break;} case 72: -#line 393 "compile.y" +#line 399 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; break;} case 76: -#line 399 "compile.y" +#line 405 "compile.y" {yyval=yyvsp[-1]; break;} case 77: -#line 400 "compile.y" +#line 406 "compile.y" {yyval=yyvsp[-1]; break;} case 78: -#line 401 "compile.y" +#line 407 "compile.y" {yyval=yyvsp[-1]; break;} case 80: -#line 404 "compile.y" +#line 410 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; break;} case 82: -#line 408 "compile.y" +#line 414 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; break;} case 84: -#line 412 "compile.y" +#line 418 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; break;} case 85: -#line 414 "compile.y" +#line 420 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP_STORE_PARAM); ; break;} case 86: -#line 418 "compile.y" +#line 424 "compile.y" { yyval=N(); OA(*yyval, OP_EXPR_CODE__STORE_PARAM, yyvsp[0]); ; break;} case 87: -#line 422 "compile.y" +#line 428 "compile.y" { yyval=N(); OA(*yyval, OP_CURLY_CODE__STORE_PARAM, yyvsp[0]); ; break;} case 91: -#line 431 "compile.y" +#line 437 "compile.y" { yyval=N(); O(*yyval, OP_PREPARE_TO_EXPRESSION); @@ -1385,15 +1391,15 @@ case 91: ; break;} case 93: -#line 440 "compile.y" +#line 446 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; break;} case 95: -#line 442 "compile.y" +#line 448 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; break;} case 97: -#line 444 "compile.y" +#line 450 "compile.y" { // we know that name_advance1 not called from ^xxx context // so we'll not check for operator call possibility as we do in name_advance2 @@ -1404,7 +1410,7 @@ case 97: ; break;} case 98: -#line 452 "compile.y" +#line 458 "compile.y" { /* stack: context */ yyval=yyvsp[0]; /* stack: context,name */ @@ -1412,14 +1418,14 @@ case 98: ; break;} case 104: -#line 465 "compile.y" +#line 471 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP_GET_ELEMENT); ; break;} case 105: -#line 469 "compile.y" +#line 475 "compile.y" { ArrayOperation* code; { @@ -1431,7 +1437,7 @@ case 105: ; break;} case 106: -#line 478 "compile.y" +#line 484 "compile.y" { yyval=N(); OA(*yyval, OP_OBJECT_POOL, yyvsp[-1]); /* stack: empty write context */ @@ -1440,7 +1446,7 @@ case 106: ; break;} case 107: -#line 484 "compile.y" +#line 490 "compile.y" { yyval=N(); O(*yyval, OP_WITH_READ); @@ -1448,18 +1454,18 @@ case 107: ; break;} case 109: -#line 489 "compile.y" +#line 495 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; break;} case 110: -#line 490 "compile.y" +#line 496 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP_GET_ELEMENT__WRITE); ; break;} case 113: -#line 499 "compile.y" +#line 505 "compile.y" { yyval=yyvsp[-1]; // stack: class name string if(*LA2S(*yyval) == BASE_NAME) { // pseudo BASE class @@ -1474,7 +1480,7 @@ case 113: ; break;} case 114: -#line 511 "compile.y" +#line 517 "compile.y" { yyval=yyvsp[-1]; if(!PC.in_call_value) { @@ -1485,7 +1491,7 @@ case 114: ; break;} case 115: -#line 523 "compile.y" +#line 529 "compile.y" { // see OP_PREPARE_TO_EXPRESSION!! if((yyval=yyvsp[0])->count()==2) // only one string literal in there? @@ -1493,159 +1499,159 @@ case 115: ; break;} case 119: -#line 532 "compile.y" +#line 538 "compile.y" { yyval = yyvsp[-1]; ; break;} case 120: -#line 533 "compile.y" +#line 539 "compile.y" { yyval = yyvsp[-1]; ; break;} case 121: -#line 534 "compile.y" +#line 540 "compile.y" { yyval = yyvsp[-1]; ; break;} case 122: -#line 536 "compile.y" +#line 542 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP_NEG) ; break;} case 123: -#line 537 "compile.y" +#line 543 "compile.y" { yyval=yyvsp[0] ; break;} case 124: -#line 538 "compile.y" +#line 544 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP_INV) ; break;} case 125: -#line 539 "compile.y" +#line 545 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP_NOT) ; break;} case 126: -#line 540 "compile.y" +#line 546 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP_DEF) ; break;} case 127: -#line 541 "compile.y" +#line 547 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP_IN) ; break;} case 128: -#line 542 "compile.y" +#line 548 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP_FEXISTS) ; break;} case 129: -#line 543 "compile.y" +#line 549 "compile.y" { yyval=yyvsp[0]; O(*yyval, OP_DEXISTS) ; break;} case 130: -#line 545 "compile.y" +#line 551 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_SUB) ; break;} case 131: -#line 546 "compile.y" +#line 552 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_ADD) ; break;} case 132: -#line 547 "compile.y" +#line 553 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MUL) ; break;} case 133: -#line 548 "compile.y" +#line 554 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_DIV) ; break;} case 134: -#line 549 "compile.y" +#line 555 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MOD) ; break;} case 135: -#line 550 "compile.y" +#line 556 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_INTDIV) ; break;} case 136: -#line 551 "compile.y" +#line 557 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SL) ; break;} case 137: -#line 552 "compile.y" +#line 558 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SR) ; break;} case 138: -#line 553 "compile.y" +#line 559 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_AND) ; break;} case 139: -#line 554 "compile.y" +#line 560 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_OR) ; break;} case 140: -#line 555 "compile.y" +#line 561 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_XOR) ; break;} case 141: -#line 556 "compile.y" +#line 562 "compile.y" { yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_AND) ; break;} case 142: -#line 557 "compile.y" +#line 563 "compile.y" { yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_OR) ; break;} case 143: -#line 558 "compile.y" +#line 564 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_LOG_XOR) ; break;} case 144: -#line 559 "compile.y" +#line 565 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LT) ; break;} case 145: -#line 560 "compile.y" +#line 566 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GT) ; break;} case 146: -#line 561 "compile.y" +#line 567 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LE) ; break;} case 147: -#line 562 "compile.y" +#line 568 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GE) ; break;} case 148: -#line 563 "compile.y" +#line 569 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_EQ) ; break;} case 149: -#line 564 "compile.y" +#line 570 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_NE) ; break;} case 150: -#line 565 "compile.y" +#line 571 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LT) ; break;} case 151: -#line 566 "compile.y" +#line 572 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GT) ; break;} case 152: -#line 567 "compile.y" +#line 573 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LE) ; break;} case 153: -#line 568 "compile.y" +#line 574 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GE) ; break;} case 154: -#line 569 "compile.y" +#line 575 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_EQ) ; break;} case 155: -#line 570 "compile.y" +#line 576 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_NE) ; break;} case 156: -#line 571 "compile.y" +#line 577 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_IS) ; break;} case 157: -#line 574 "compile.y" +#line 580 "compile.y" { yyval=N(); OA(*yyval, OP_STRING_POOL, yyvsp[0]); /* stack: empty write context */ @@ -1654,18 +1660,18 @@ case 157: ; break;} case 158: -#line 583 "compile.y" +#line 589 "compile.y" { // optimized from OP_STRING+OP_WRITE_VALUE to OP_STRING__WRITE change_string_literal_to_write_string_literal(*(yyval=yyvsp[0])) ; break;} case 159: -#line 588 "compile.y" +#line 594 "compile.y" { yyval=VL(new VVoid(), 0, 0, 0) ; break;} case 160: -#line 589 "compile.y" +#line 595 "compile.y" { yyval=N() ; break;} } @@ -1890,7 +1896,7 @@ yyerrhandle: } return 1; } -#line 591 "compile.y" +#line 597 "compile.y" #endif @@ -1910,6 +1916,14 @@ yyerrhandle: 4:[^({]=pop */ +inline void ungetc(Parse_control& pc, uint last_line_end_col) { + pc.source--; + if(pc.pos.col==0) { + --pc.pos.line; pc.pos.col=last_line_end_col; + } else + --pc.pos.col; + +} static int yylex(YYSTYPE *lvalp, void *apc) { register Parse_control& pc=*static_cast(apc); @@ -1934,10 +1948,9 @@ static int yylex(YYSTYPE *lvalp, void *a // fprintf(stderr, "\nchar: %c %02X; nestage: %d, sp=%d", c, c, lexical_brackets_nestage, pc.sp); if(c=='\n') { - pc.pos.line++; - pc.pos.col=0; + pc.pos_next_line(); } else - pc.pos.col++; + pc.pos_next_c(c); if(c=='@' && pc.pos.col==0+1) { if(pc.ls==LS_DEF_SPECIAL_BODY) { @@ -1983,7 +1996,7 @@ default: if(!pc.string_start) pc.string_start=begin_pos; // append piece till ^ - pc.string.append_strdup(begin, end-begin); + pc.string.append_strdup_know_length(begin, end-begin); } // reset piece 'begin' position & line begin=pc.source; // ->punctuation @@ -1999,7 +2012,7 @@ default: if(!pc.string_start) pc.string_start=begin_pos; // append piece till ^ - pc.string.append_strdup(begin, end-begin); + pc.string.append_strdup_know_length(begin, end-begin); } // #HH ? if(pc.source[0]=='#' && pc.source[1] && pc.source[2]) { @@ -2032,7 +2045,7 @@ default: if(!pc.string_start) pc.string_start=begin_pos; // append piece till # - pc.string.append_strdup(begin, end-begin); + pc.string.append_strdup_know_length(begin, end-begin); } // fall into COMMENT lexical state [wait for \n] push_LS(pc, LS_USER_COMMENT); @@ -2042,7 +2055,7 @@ default: // USER'S = NOT OURS case LS_USER: - case LS_NAME_SQUARE_PART: // name.[here].xxx + case LS_NAME_SQUARE_PART: // name.[here].xxx if(pc.trim_bof) switch(c) { case '\n': case ' ': case '\t': @@ -2177,7 +2190,7 @@ default: if(!pc.string_start) pc.string_start=begin_pos; // append piece till # - pc.string.append_strdup(begin, end-begin); + pc.string.append_strdup_know_length(begin, end-begin); } // fall into COMMENT lexical state [wait for \n] push_LS(pc, LS_EXPRESSION_COMMENT); @@ -2360,7 +2373,7 @@ default: // expression integer division case '\\': pop_LS(pc); - pc.source--; if(--pc.pos.col<0) { pc.pos.line--; pc.pos.col=-1; } + pc.ungetc(); result=EON; goto break2; } @@ -2372,7 +2385,7 @@ default: switch(c) { case ':': pop_LS(pc); - pc.source--; if(--pc.pos.col<0) { pc.pos.line--; pc.pos.col=-1; } + pc.ungetc(); result=EON; goto break2; } @@ -2392,7 +2405,7 @@ default: // before call case '^': pop_LS(pc); - pc.source--; if(--pc.pos.col<0) { pc.pos.line--; pc.pos.col=-1; } + pc.ungetc(); result=EON; goto break2; case '[': @@ -2589,7 +2602,7 @@ default: RC; } pop_LS(pc); - pc.source--; if(--pc.pos.col<0) { pc.pos.line--; pc.pos.col=-1; } + pc.ungetc(); result=EON; goto break2; } @@ -2611,11 +2624,11 @@ break2: if(!pc.string_start) pc.string_start=begin_pos; // append it - pc.string.append_strdup(begin, end-begin); + pc.string.append_strdup_know_length(begin, end-begin); } } if(!pc.string.is_empty()) { // something accumulated? - // create STRING value: array of OP_VALUE+vstring + // create STRING value: array of OP_VALUE+origin+vstring *lvalp=VL( new VString(*new String(pc.string, String::L_CLEAN)), pc.file_no, pc.string_start.line, pc.string_start.col);