|
|
| version 1.81.2.5, 2003/01/31 14:03:53 | version 1.81.2.13.2.32, 2003/04/04 06:41:47 |
|---|---|
| Line 57 | Line 57 |
| -#: in iis make up specialized Pool object for that | -#: in iis make up specialized Pool object for that |
| */ | */ |
| #define YYSTYPE ArrayOperationPtr | #define YYSTYPE ArrayOperation* |
| #define YYPARSE_PARAM pc | #define YYPARSE_PARAM pc |
| #define YYLEX_PARAM pc | #define YYLEX_PARAM pc |
| #define YYDEBUG 1 | #define YYDEBUG 1 |
| #define YYERROR_VERBOSE 1 | #define YYERROR_VERBOSE 1 |
| #define yyerror(msg) real_yyerror((parse_control *)pc, msg) | #define yyerror(msg) real_yyerror((Parse_control *)pc, msg) |
| #define YYPRINT(file, type, value) yyprint(file, type, value) | #define YYPRINT(file, type, value) yyprint(file, type, value) |
| // includes | |
| #include "compile_tools.h" | #include "compile_tools.h" |
| #include "pa_value.h" | #include "pa_value.h" |
| #include "pa_request.h" | #include "pa_request.h" |
| Line 74 | Line 76 |
| #include "pa_vvoid.h" | #include "pa_vvoid.h" |
| #include "pa_vmethod_frame.h" | #include "pa_vmethod_frame.h" |
| // defines | |
| #define USE_CONTROL_METHOD_NAME "USE" | #define USE_CONTROL_METHOD_NAME "USE" |
| static int real_yyerror(parse_control *pc, char *s); | // forwards |
| static void yyprint(FILE *file, int type, YYSTYPE value); | |
| static int yylex(YYSTYPE *lvalp, void *pc); | 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 | // local convinient inplace typecast & var |
| #define PC (*(parse_control *)pc) | #undef PC |
| #define PC (*(Parse_control *)pc) | |
| #undef POOL | |
| #define POOL (*PC.pool) | #define POOL (*PC.pool) |
| #undef NEW | |
| #define NEW new(POOL) | |
| #ifndef DOXYGEN | #ifndef DOXYGEN |
| #ifndef YYSTYPE | #ifndef YYSTYPE |
| #define YYSTYPE int | #define YYSTYPE int |
| Line 210 static const short yyrhs[] = { 62, | Line 216 static const short yyrhs[] = { 62, |
| #if YYDEBUG != 0 | #if YYDEBUG != 0 |
| static const short yyrline[] = { 0, | static const short yyrline[] = { 0, |
| 115, 123, 125, 125, 126, 128, 128, 130, 201, 201, | 121, 129, 131, 131, 132, 134, 134, 136, 208, 208, |
| 202, 202, 203, 204, 204, 206, 235, 235, 236, 237, | 209, 209, 210, 211, 211, 213, 242, 242, 243, 244, |
| 237, 238, 238, 240, 240, 244, 244, 246, 246, 247, | 244, 245, 245, 247, 247, 251, 251, 253, 253, 254, |
| 247, 248, 248, 248, 252, 259, 260, 260, 261, 262, | 254, 255, 255, 255, 259, 266, 267, 267, 268, 269, |
| 264, 265, 287, 288, 288, 292, 296, 298, 299, 300, | 271, 272, 294, 295, 295, 299, 303, 305, 306, 307, |
| 317, 322, 324, 326, 327, 329, 335, 343, 349, 351, | 324, 329, 331, 333, 334, 336, 342, 350, 356, 358, |
| 352, 354, 360, 361, 361, 365, 371, 374, 377, 390, | 359, 361, 367, 368, 368, 372, 378, 381, 384, 397, |
| 392, 392, 393, 395, 396, 398, 399, 400, 401, 403, | 399, 399, 400, 402, 403, 405, 406, 407, 408, 410, |
| 405, 407, 409, 411, 413, 417, 421, 425, 427, 428, | 412, 414, 416, 418, 420, 424, 428, 432, 434, 435, |
| 430, 439, 439, 441, 441, 442, 443, 451, 456, 458, | 437, 446, 446, 448, 448, 449, 450, 458, 463, 465, |
| 460, 461, 462, 464, 468, 477, 483, 488, 488, 489, | 467, 468, 469, 471, 475, 484, 490, 495, 495, 496, |
| 494, 496, 498, 510, 522, 527, 529, 530, 531, 532, | 501, 503, 505, 517, 529, 534, 536, 537, 538, 539, |
| 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, | 540, 542, 543, 544, 545, 546, 547, 548, 549, 551, |
| 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, | 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, |
| 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, | 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, |
| 565, 566, 567, 568, 569, 570, 573, 582, 587, 588 | 572, 573, 574, 575, 576, 577, 580, 589, 594, 595 |
| }; | }; |
| #endif | #endif |
| Line 1032 yyreduce: | Line 1038 yyreduce: |
| switch (yyn) { | switch (yyn) { |
| case 1: | case 1: |
| #line 116 "compile.y" | #line 122 "compile.y" |
| { | { |
| MethodPtr method(new Method(main_method_name, Method::CT_ANY, | Method& method=*new Method(Method::CT_ANY, |
| 0, 0, /*min, max numbered_params_count*/ | 0, 0, /*min, max numbered_params_count*/ |
| ArrayStringPtr(0)/*param_names*/, ArrayStringPtr(0)/*local_names*/, | 0/*param_names*/, 0/*local_names*/, |
| yyvsp[0]/*parser_code*/, 0/*native_code*/)); | 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;} | break;} |
| case 8: | case 8: |
| #line 131 "compile.y" | #line 137 "compile.y" |
| { | { |
| StringPtr command=LA2S(*yyvsp[-2]); | const String& command=*LA2S(*yyvsp[-2]); |
| YYSTYPE strings_code=yyvsp[0]; | YYSTYPE strings_code=yyvsp[0]; |
| if(strings_code->count()<1*2) { | if(strings_code->count()<1*OPERATIONS_PER_OPVALUE) { |
| strcpy(PC.error, "@"); | strcpy(PC.error, "@"); |
| strcat(PC.error, command->cstr()); | strcat(PC.error, command.cstr()); |
| strcat(PC.error, " is empty"); | strcat(PC.error, " is empty"); |
| YYERROR; | YYERROR; |
| } | } |
| if(*command==CLASS_NAME) { | if(command==CLASS_NAME) { |
| if(PC.cclass->base_class()) { // already changed from default? | if(PC.cclass->base_class()) { // already changed from default? |
| strcpy(PC.error, "class already have a name '"); | strcpy(PC.error, "class already have a name '"); |
| strncat(PC.error, PC.cclass->name()->cstr(), 100); | strncat(PC.error, PC.cclass->name().cstr(), 100); |
| strcat(PC.error, "'"); | strcat(PC.error, "'"); |
| YYERROR; | YYERROR; |
| } | } |
| if(strings_code->count()==1*2) { | if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) { |
| // new class' name | // new class' name |
| StringPtr name=LA2S(*strings_code); | const String& name=*LA2S(*strings_code); |
| // creating the class | // creating the class |
| PC.cclass=VStateless_classPtr(new VClass); | VStateless_class* cclass=new VClass; |
| PC.cclass=cclass; | |
| PC.cclass->set_name(name); | PC.cclass->set_name(name); |
| // append to request's classes | // append to request's classes |
| PC.request->classes().put(name, PC.cclass); | PC.request.classes().put(name, cclass); |
| } else { | } 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; | YYERROR; |
| } | } |
| } else if(*command==USE_CONTROL_METHOD_NAME) { | } else if(command==USE_CONTROL_METHOD_NAME) { |
| for(int i=0; i<strings_code->count(); i+=2) | for(size_t i=0; i<strings_code->count(); i+=OPERATIONS_PER_OPVALUE) |
| PC.request->use_file(*PC.request->main_class, LA2S(*strings_code, i)); | PC.request.use_file(PC.request.main_class, *LA2S(*strings_code, i)); |
| } else if(*command==BASE_NAME) { | } else if(command==BASE_NAME) { |
| if(PC.cclass->base_class()) { // already changed from default? | if(PC.cclass->base_class()) { // already changed from default? |
| strcpy(PC.error, "class already have a base '"); | strcpy(PC.error, "class already have a base '"); |
| strncat(PC.error, PC.cclass->base_class()->name()->cstr(), 100); | strncat(PC.error, PC.cclass->base_class()->name().cstr(), 100); |
| strcat(PC.error, "'"); | strcat(PC.error, "'"); |
| YYERROR; | YYERROR; |
| } | } |
| if(strings_code->count()==1*2) { | if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) { |
| StringPtr base_name=LA2S(*strings_code); | const String& base_name=*LA2S(*strings_code); |
| if(ValuePtr base_class_value=PC.request->classes().get(base_name)) { | if(Value* base_class_value=PC.request.classes().get(base_name)) { |
| // @CLASS == @BASE sanity check | // @CLASS == @BASE sanity check |
| if(VStateless_class *base_class=base_class_value->get_class()) { | if(VStateless_class *base_class=base_class_value->get_class()) { |
| if(PC.cclass.get()==base_class) { | if(PC.cclass==base_class) { |
| strcpy(PC.error, "@"CLASS_NAME" equals @"BASE_NAME); | strcpy(PC.error, "@"CLASS_NAME" equals @"BASE_NAME); |
| YYERROR; | YYERROR; |
| } | } |
| PC.cclass->get_class()->set_base(base_class); | PC.cclass->get_class()->set_base(base_class); |
| } else { // they asked to derive from a class without methods ['env' & co] | } else { // they asked to derive from a class without methods ['env' & co] |
| strcpy(PC.error, base_name->cstr()); | strcpy(PC.error, base_name.cstr()); |
| strcat(PC.error, ": you can not derive from this class in @"BASE_NAME); | strcat(PC.error, ": you can not derive from this class in @"BASE_NAME); |
| YYERROR; | YYERROR; |
| } | } |
| } else { | } else { |
| strcpy(PC.error, base_name->cstr()); | strcpy(PC.error, base_name.cstr()); |
| strcat(PC.error, ": undefined class in @"BASE_NAME); | strcat(PC.error, ": undefined class in @"BASE_NAME); |
| YYERROR; | YYERROR; |
| } | } |
| Line 1107 case 8: | Line 1114 case 8: |
| } | } |
| } else { | } else { |
| strcpy(PC.error, "'"); | strcpy(PC.error, "'"); |
| strncat(PC.error, command->cstr(), MAX_STRING/2); | strncat(PC.error, command.cstr(), MAX_STRING/2); |
| strcat(PC.error, "' invalid special name. valid names are " | strcat(PC.error, "' invalid special name. valid names are " |
| "'"CLASS_NAME"', '"USE_CONTROL_METHOD_NAME"' and '"BASE_NAME"'"); | "'"CLASS_NAME"', '"USE_CONTROL_METHOD_NAME"' and '"BASE_NAME"'"); |
| YYERROR; | YYERROR; |
| Line 1115 case 8: | Line 1122 case 8: |
| ; | ; |
| break;} | break;} |
| case 12: | case 12: |
| #line 202 "compile.y" | #line 209 "compile.y" |
| { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 16: | case 16: |
| #line 207 "compile.y" | #line 214 "compile.y" |
| { | { |
| StringPtr name=LA2S(*yyvsp[-5]); | const String& name=*LA2S(*yyvsp[-5]); |
| YYSTYPE params_names_code=yyvsp[-4]; | YYSTYPE params_names_code=yyvsp[-4]; |
| ArrayStringPtr params_names; | ArrayString* params_names=0; |
| if(int size=params_names_code->count()) { | if(int size=params_names_code->count()) { |
| params_names=ArrayStringPtr(new ArrayString); | params_names=new ArrayString; |
| for(int i=0; i<size; i+=2) | for(int i=0; i<size; i+=OPERATIONS_PER_OPVALUE) |
| *params_names+=LA2S(*params_names_code, i); | *params_names+=LA2S(*params_names_code, i); |
| } | } |
| YYSTYPE locals_names_code=yyvsp[-3]; | YYSTYPE locals_names_code=yyvsp[-3]; |
| ArrayStringPtr locals_names; | ArrayString* locals_names=0; |
| if(int size=locals_names_code->count()) { | if(int size=locals_names_code->count()) { |
| locals_names=ArrayStringPtr(new ArrayString); | locals_names=new ArrayString; |
| for(int i=0; i<size; i+=2) | for(int i=0; i<size; i+=OPERATIONS_PER_OPVALUE) |
| *locals_names+=LA2S(*locals_names_code, i); | *locals_names+=LA2S(*locals_names_code, i); |
| } | } |
| MethodPtr method(new Method( | Method& method=*new Method( |
| name, | //name, |
| Method::CT_ANY, | Method::CT_ANY, |
| 0, 0/*min,max numbered_params_count*/, | 0, 0/*min,max numbered_params_count*/, |
| params_names, locals_names, | params_names, locals_names, |
| yyvsp[0], 0)); | yyvsp[0], 0); |
| PC.cclass->add_method(name, method); | PC.cclass->add_method(PC.alias_method(name), method); |
| ; | ; |
| break;} | break;} |
| case 19: | case 19: |
| #line 236 "compile.y" | #line 243 "compile.y" |
| {yyval=yyvsp[-1]; | {yyval=yyvsp[-1]; |
| break;} | break;} |
| case 23: | case 23: |
| #line 238 "compile.y" | #line 245 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 29: | case 29: |
| #line 246 "compile.y" | #line 253 "compile.y" |
| { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 35: | case 35: |
| #line 252 "compile.y" | #line 259 "compile.y" |
| { | { |
| yyval=yyvsp[0]; /* stack: resulting value */ | yyval=yyvsp[0]; /* stack: resulting value */ |
| changetail_or_append(*yyval, | changetail_or_append(*yyval, |
| Line 1171 case 35: | Line 1178 case 35: |
| ; | ; |
| break;} | break;} |
| case 36: | case 36: |
| #line 259 "compile.y" | #line 266 "compile.y" |
| { yyval=yyvsp[0] ; | { yyval=yyvsp[0] ; |
| break;} | break;} |
| case 39: | case 39: |
| #line 261 "compile.y" | #line 268 "compile.y" |
| { yyval=yyvsp[-1] ; | { yyval=yyvsp[-1] ; |
| break;} | break;} |
| case 42: | case 42: |
| #line 265 "compile.y" | #line 272 "compile.y" |
| { | { |
| yyval=N(); | yyval=N(); |
| ArrayOperationPtr diving_code=yyvsp[0]; | ArrayOperation* diving_code=yyvsp[0]; |
| StringPtr first_name=LA2S(*diving_code); | const String* first_name=LA2S(*diving_code); |
| // self.xxx... -> xxx... | // 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) { | if(first_name && *first_name==SELF_ELEMENT_NAME) { |
| O(*yyval, OP_WITH_SELF); /* stack: starting context */ | O(*yyval, OP_WITH_SELF); /* stack: starting context */ |
| P(*yyval, *diving_code, | P(*yyval, *diving_code, |
| /* skip over... */ | /* 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 { | } else { |
| O(*yyval, OP_WITH_READ); /* stack: starting context */ | O(*yyval, OP_WITH_READ); /* stack: starting context */ |
| // ^if ELEMENT -> ^if ELEMENT_OR_OPERATOR | // ^if ELEMENT -> ^if ELEMENT_OR_OPERATOR |
| // OP_VALUE+string+OP_GET_ELEMENT. -> OP_VALUE+string+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()==3) | if(PC.in_call_value && diving_code->count()==4) |
| (*diving_code)[2].code=OP_GET_ELEMENT_OR_OPERATOR; | diving_code->put(4-1, OP_GET_ELEMENT_OR_OPERATOR); |
| P(*yyval, *diving_code); | P(*yyval, *diving_code); |
| } | } |
| /* diving code; stack: current context */ | /* diving code; stack: current context */ |
| ; | ; |
| break;} | break;} |
| case 43: | case 43: |
| #line 287 "compile.y" | #line 294 "compile.y" |
| { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 45: | case 45: |
| #line 288 "compile.y" | #line 295 "compile.y" |
| { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 46: | case 46: |
| #line 292 "compile.y" | #line 299 "compile.y" |
| { | { |
| yyval=yyvsp[-1]; /* stack: context,name */ | yyval=yyvsp[-1]; /* stack: context,name */ |
| P(*yyval, *yyvsp[0]); /* stack: context,name,constructor_value */ | P(*yyval, *yyvsp[0]); /* stack: context,name,constructor_value */ |
| ; | ; |
| break;} | break;} |
| case 50: | case 50: |
| #line 300 "compile.y" | #line 307 "compile.y" |
| { | { |
| yyval=N(); | yyval=N(); |
| ArrayOperationPtr diving_code=yyvsp[0]; | ArrayOperation* diving_code=yyvsp[0]; |
| StringPtr first_name=LA2S(*diving_code); | const String* first_name=LA2S(*diving_code); |
| // $self.xxx... -> $xxx... | // $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) { | if(first_name && *first_name==SELF_ELEMENT_NAME) { |
| O(*yyval, OP_WITH_SELF); /* stack: starting context */ | O(*yyval, OP_WITH_SELF); /* stack: starting context */ |
| P(*yyval, *diving_code, | P(*yyval, *diving_code, |
| /* skip over... */ | /* 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 { | } else { |
| O(*yyval, OP_WITH_ROOT); /* stack: starting context */ | O(*yyval, OP_WITH_ROOT); /* stack: starting context */ |
| P(*yyval, *diving_code); | P(*yyval, *diving_code); |
| Line 1239 case 50: | Line 1246 case 50: |
| ; | ; |
| break;} | break;} |
| case 51: | case 51: |
| #line 317 "compile.y" | #line 324 "compile.y" |
| { | { |
| yyval=N(); | yyval=N(); |
| O(*yyval, OP_WITH_WRITE); /* stack: starting context */ | O(*yyval, OP_WITH_WRITE); /* stack: starting context */ |
| Line 1247 case 51: | Line 1254 case 51: |
| ; | ; |
| break;} | break;} |
| case 52: | case 52: |
| #line 322 "compile.y" | #line 329 "compile.y" |
| { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 56: | case 56: |
| #line 329 "compile.y" | #line 336 "compile.y" |
| { | { |
| // stack: context, name | // stack: context, name |
| yyval=yyvsp[-1]; // stack: context, name, value | yyval=yyvsp[-1]; // stack: context, name, value |
| Line 1259 case 56: | Line 1266 case 56: |
| ; | ; |
| break;} | break;} |
| case 57: | case 57: |
| #line 335 "compile.y" | #line 342 "compile.y" |
| { | { |
| yyval=N(); | yyval=N(); |
| O(*yyval, OP_PREPARE_TO_EXPRESSION); | O(*yyval, OP_PREPARE_TO_EXPRESSION); |
| Line 1269 case 57: | Line 1276 case 57: |
| ; | ; |
| break;} | break;} |
| case 58: | case 58: |
| #line 343 "compile.y" | #line 350 "compile.y" |
| { | { |
| // stack: context, name | // stack: context, name |
| yyval=N(); | yyval=N(); |
| Line 1277 case 58: | Line 1284 case 58: |
| ; | ; |
| break;} | break;} |
| case 62: | case 62: |
| #line 354 "compile.y" | #line 361 "compile.y" |
| { | { |
| yyval=N(); | yyval=N(); |
| OA(*yyval, OP_OBJECT_POOL, yyvsp[0]); /* stack: empty write context */ | OA(*yyval, OP_OBJECT_POOL, yyvsp[0]); /* stack: empty write context */ |
| Line 1286 case 62: | Line 1293 case 62: |
| ; | ; |
| break;} | break;} |
| case 65: | case 65: |
| #line 361 "compile.y" | #line 368 "compile.y" |
| { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 66: | case 66: |
| #line 365 "compile.y" | #line 372 "compile.y" |
| { | { |
| yyval=yyvsp[0]; /* stack: value */ | yyval=yyvsp[0]; /* stack: value */ |
| changetail_or_append(*yyval, | changetail_or_append(*yyval, |
| Line 1299 case 66: | Line 1306 case 66: |
| ; | ; |
| break;} | break;} |
| case 67: | case 67: |
| #line 371 "compile.y" | #line 378 "compile.y" |
| { | { |
| PC.in_call_value=true; | PC.in_call_value=true; |
| ; | ; |
| break;} | break;} |
| case 68: | case 68: |
| #line 374 "compile.y" | #line 381 "compile.y" |
| { | { |
| PC.in_call_value=false; | PC.in_call_value=false; |
| ; | ; |
| break;} | break;} |
| case 69: | case 69: |
| #line 377 "compile.y" | #line 384 "compile.y" |
| { /* ^field.$method{vasya} */ | { /* ^field.$method{vasya} */ |
| yyval=yyvsp[-3]; /* with_xxx,diving code; stack: context,method_junction */ | yyval=yyvsp[-3]; /* with_xxx,diving code; stack: context,method_junction */ |
| YYSTYPE params_code=yyvsp[-1]; | YYSTYPE params_code=yyvsp[-1]; |
| if(params_code->count()==3) { // probably [] case. [OP_VALUE + Void + STORE_PARAM] | if(params_code->count()==4) { // probably [] case. [OP_VALUE+origin+Void+STORE_PARAM] |
| if(ValuePtr value=LA2V(*params_code)) // it is OP_VALUE + value? | if(Value* value=LA2V(*params_code)) // it is OP_VALUE+origin+value? |
| if(!value->is_defined()) // value is VVoid? | if(!value->is_defined()) // value is VVoid? |
| params_code=YYSTYPE(0); // ^zzz[] case. don't append lone empty param. | params_code=0; // ^zzz[] case. don't append lone empty param. |
| } | } |
| /* stack: context, method_junction */ | /* stack: context, method_junction */ |
| OA(*yyval, OP_CALL, params_code); // method_frame=make frame(pop junction); ncontext=pop; call(ncontext,method_frame) stack: value | OA(*yyval, OP_CALL, params_code); // method_frame=make frame(pop junction); ncontext=pop; call(ncontext,method_frame) stack: value |
| ; | ; |
| break;} | break;} |
| case 72: | case 72: |
| #line 392 "compile.y" | #line 399 "compile.y" |
| { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 76: | case 76: |
| #line 398 "compile.y" | #line 405 "compile.y" |
| {yyval=yyvsp[-1]; | {yyval=yyvsp[-1]; |
| break;} | break;} |
| case 77: | case 77: |
| #line 399 "compile.y" | #line 406 "compile.y" |
| {yyval=yyvsp[-1]; | {yyval=yyvsp[-1]; |
| break;} | break;} |
| case 78: | case 78: |
| #line 400 "compile.y" | #line 407 "compile.y" |
| {yyval=yyvsp[-1]; | {yyval=yyvsp[-1]; |
| break;} | break;} |
| case 80: | case 80: |
| #line 403 "compile.y" | #line 410 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 82: | case 82: |
| #line 407 "compile.y" | #line 414 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 84: | case 84: |
| #line 411 "compile.y" | #line 418 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 85: | case 85: |
| #line 413 "compile.y" | #line 420 "compile.y" |
| { | { |
| yyval=yyvsp[0]; | yyval=yyvsp[0]; |
| O(*yyval, OP_STORE_PARAM); | O(*yyval, OP_STORE_PARAM); |
| ; | ; |
| break;} | break;} |
| case 86: | case 86: |
| #line 417 "compile.y" | #line 424 "compile.y" |
| { | { |
| yyval=N(); | yyval=N(); |
| OA(*yyval, OP_EXPR_CODE__STORE_PARAM, yyvsp[0]); | OA(*yyval, OP_EXPR_CODE__STORE_PARAM, yyvsp[0]); |
| ; | ; |
| break;} | break;} |
| case 87: | case 87: |
| #line 421 "compile.y" | #line 428 "compile.y" |
| { | { |
| yyval=N(); | yyval=N(); |
| OA(*yyval, OP_CURLY_CODE__STORE_PARAM, yyvsp[0]); | OA(*yyval, OP_CURLY_CODE__STORE_PARAM, yyvsp[0]); |
| ; | ; |
| break;} | break;} |
| case 91: | case 91: |
| #line 430 "compile.y" | #line 437 "compile.y" |
| { | { |
| yyval=N(); | yyval=N(); |
| O(*yyval, OP_PREPARE_TO_EXPRESSION); | O(*yyval, OP_PREPARE_TO_EXPRESSION); |
| Line 1384 case 91: | Line 1391 case 91: |
| ; | ; |
| break;} | break;} |
| case 93: | case 93: |
| #line 439 "compile.y" | #line 446 "compile.y" |
| { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 95: | case 95: |
| #line 441 "compile.y" | #line 448 "compile.y" |
| { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 97: | case 97: |
| #line 443 "compile.y" | #line 450 "compile.y" |
| { | { |
| // we know that name_advance1 not called from ^xxx context | // 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 | // so we'll not check for operator call possibility as we do in name_advance2 |
| Line 1403 case 97: | Line 1410 case 97: |
| ; | ; |
| break;} | break;} |
| case 98: | case 98: |
| #line 451 "compile.y" | #line 458 "compile.y" |
| { | { |
| /* stack: context */ | /* stack: context */ |
| yyval=yyvsp[0]; /* stack: context,name */ | yyval=yyvsp[0]; /* stack: context,name */ |
| Line 1411 case 98: | Line 1418 case 98: |
| ; | ; |
| break;} | break;} |
| case 104: | case 104: |
| #line 464 "compile.y" | #line 471 "compile.y" |
| { | { |
| yyval=yyvsp[0]; | yyval=yyvsp[0]; |
| O(*yyval, OP_GET_ELEMENT); | O(*yyval, OP_GET_ELEMENT); |
| ; | ; |
| break;} | break;} |
| case 105: | case 105: |
| #line 468 "compile.y" | #line 475 "compile.y" |
| { | { |
| ArrayOperationPtr code; | ArrayOperation* code; |
| { | { |
| change_string_literal_to_write_string_literal(*(code=yyvsp[-1])); | change_string_literal_to_write_string_literal(*(code=yyvsp[-1])); |
| P(*code, *yyvsp[0]); | P(*code, *yyvsp[0]); |
| Line 1430 case 105: | Line 1437 case 105: |
| ; | ; |
| break;} | break;} |
| case 106: | case 106: |
| #line 477 "compile.y" | #line 484 "compile.y" |
| { | { |
| yyval=N(); | yyval=N(); |
| OA(*yyval, OP_OBJECT_POOL, yyvsp[-1]); /* stack: empty write context */ | OA(*yyval, OP_OBJECT_POOL, yyvsp[-1]); /* stack: empty write context */ |
| Line 1439 case 106: | Line 1446 case 106: |
| ; | ; |
| break;} | break;} |
| case 107: | case 107: |
| #line 483 "compile.y" | #line 490 "compile.y" |
| { | { |
| yyval=N(); | yyval=N(); |
| O(*yyval, OP_WITH_READ); | O(*yyval, OP_WITH_READ); |
| Line 1447 case 107: | Line 1454 case 107: |
| ; | ; |
| break;} | break;} |
| case 109: | case 109: |
| #line 488 "compile.y" | #line 495 "compile.y" |
| { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; | { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ; |
| break;} | break;} |
| case 110: | case 110: |
| #line 489 "compile.y" | #line 496 "compile.y" |
| { | { |
| yyval=yyvsp[0]; | yyval=yyvsp[0]; |
| O(*yyval, OP_GET_ELEMENT__WRITE); | O(*yyval, OP_GET_ELEMENT__WRITE); |
| ; | ; |
| break;} | break;} |
| case 113: | case 113: |
| #line 498 "compile.y" | #line 505 "compile.y" |
| { | { |
| yyval=yyvsp[-1]; // stack: class name string | yyval=yyvsp[-1]; // stack: class name string |
| if(*LA2S(*yyval) == BASE_NAME) { // pseude BASE class | if(*LA2S(*yyval) == BASE_NAME) { // pseudo BASE class |
| if(VStateless_class* base=PC.cclass->base_class()) { | if(VStateless_class* base=PC.cclass->base_class()) { |
| change_string_literal_value(*yyval, base->name()); | change_string_literal_value(*yyval, base->name()); |
| } else { | } else { |
| Line 1473 case 113: | Line 1480 case 113: |
| ; | ; |
| break;} | break;} |
| case 114: | case 114: |
| #line 510 "compile.y" | #line 517 "compile.y" |
| { | { |
| yyval=yyvsp[-1]; | yyval=yyvsp[-1]; |
| if(!PC.in_call_value) { | if(!PC.in_call_value) { |
| Line 1484 case 114: | Line 1491 case 114: |
| ; | ; |
| break;} | break;} |
| case 115: | case 115: |
| #line 522 "compile.y" | #line 529 "compile.y" |
| { | { |
| // see OP_PREPARE_TO_EXPRESSION!! | // see OP_PREPARE_TO_EXPRESSION!! |
| if((yyval=yyvsp[0])->count()==2) // only one string literal in there? | if((yyval=yyvsp[0])->count()==2) // only one string literal in there? |
| Line 1492 case 115: | Line 1499 case 115: |
| ; | ; |
| break;} | break;} |
| case 119: | case 119: |
| #line 531 "compile.y" | #line 538 "compile.y" |
| { yyval = yyvsp[-1]; ; | { yyval = yyvsp[-1]; ; |
| break;} | break;} |
| case 120: | case 120: |
| #line 532 "compile.y" | #line 539 "compile.y" |
| { yyval = yyvsp[-1]; ; | { yyval = yyvsp[-1]; ; |
| break;} | break;} |
| case 121: | case 121: |
| #line 533 "compile.y" | #line 540 "compile.y" |
| { yyval = yyvsp[-1]; ; | { yyval = yyvsp[-1]; ; |
| break;} | break;} |
| case 122: | case 122: |
| #line 535 "compile.y" | #line 542 "compile.y" |
| { yyval=yyvsp[0]; O(*yyval, OP_NEG) ; | { yyval=yyvsp[0]; O(*yyval, OP_NEG) ; |
| break;} | break;} |
| case 123: | case 123: |
| #line 536 "compile.y" | #line 543 "compile.y" |
| { yyval=yyvsp[0] ; | { yyval=yyvsp[0] ; |
| break;} | break;} |
| case 124: | case 124: |
| #line 537 "compile.y" | #line 544 "compile.y" |
| { yyval=yyvsp[0]; O(*yyval, OP_INV) ; | { yyval=yyvsp[0]; O(*yyval, OP_INV) ; |
| break;} | break;} |
| case 125: | case 125: |
| #line 538 "compile.y" | #line 545 "compile.y" |
| { yyval=yyvsp[0]; O(*yyval, OP_NOT) ; | { yyval=yyvsp[0]; O(*yyval, OP_NOT) ; |
| break;} | break;} |
| case 126: | case 126: |
| #line 539 "compile.y" | #line 546 "compile.y" |
| { yyval=yyvsp[0]; O(*yyval, OP_DEF) ; | { yyval=yyvsp[0]; O(*yyval, OP_DEF) ; |
| break;} | break;} |
| case 127: | case 127: |
| #line 540 "compile.y" | #line 547 "compile.y" |
| { yyval=yyvsp[0]; O(*yyval, OP_IN) ; | { yyval=yyvsp[0]; O(*yyval, OP_IN) ; |
| break;} | break;} |
| case 128: | case 128: |
| #line 541 "compile.y" | #line 548 "compile.y" |
| { yyval=yyvsp[0]; O(*yyval, OP_FEXISTS) ; | { yyval=yyvsp[0]; O(*yyval, OP_FEXISTS) ; |
| break;} | break;} |
| case 129: | case 129: |
| #line 542 "compile.y" | #line 549 "compile.y" |
| { yyval=yyvsp[0]; O(*yyval, OP_DEXISTS) ; | { yyval=yyvsp[0]; O(*yyval, OP_DEXISTS) ; |
| break;} | break;} |
| case 130: | case 130: |
| #line 544 "compile.y" | #line 551 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_SUB) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_SUB) ; |
| break;} | break;} |
| case 131: | case 131: |
| #line 545 "compile.y" | #line 552 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_ADD) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_ADD) ; |
| break;} | break;} |
| case 132: | case 132: |
| #line 546 "compile.y" | #line 553 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MUL) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MUL) ; |
| break;} | break;} |
| case 133: | case 133: |
| #line 547 "compile.y" | #line 554 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_DIV) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_DIV) ; |
| break;} | break;} |
| case 134: | case 134: |
| #line 548 "compile.y" | #line 555 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MOD) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MOD) ; |
| break;} | break;} |
| case 135: | case 135: |
| #line 549 "compile.y" | #line 556 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_INTDIV) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_INTDIV) ; |
| break;} | break;} |
| case 136: | case 136: |
| #line 550 "compile.y" | #line 557 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SL) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SL) ; |
| break;} | break;} |
| case 137: | case 137: |
| #line 551 "compile.y" | #line 558 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SR) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SR) ; |
| break;} | break;} |
| case 138: | case 138: |
| #line 552 "compile.y" | #line 559 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_AND) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_AND) ; |
| break;} | break;} |
| case 139: | case 139: |
| #line 553 "compile.y" | #line 560 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_OR) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_OR) ; |
| break;} | break;} |
| case 140: | case 140: |
| #line 554 "compile.y" | #line 561 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_XOR) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_XOR) ; |
| break;} | break;} |
| case 141: | case 141: |
| #line 555 "compile.y" | #line 562 "compile.y" |
| { yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_AND) ; | { yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_AND) ; |
| break;} | break;} |
| case 142: | case 142: |
| #line 556 "compile.y" | #line 563 "compile.y" |
| { yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_OR) ; | { yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_OR) ; |
| break;} | break;} |
| case 143: | case 143: |
| #line 557 "compile.y" | #line 564 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_LOG_XOR) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_LOG_XOR) ; |
| break;} | break;} |
| case 144: | case 144: |
| #line 558 "compile.y" | #line 565 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LT) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LT) ; |
| break;} | break;} |
| case 145: | case 145: |
| #line 559 "compile.y" | #line 566 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GT) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GT) ; |
| break;} | break;} |
| case 146: | case 146: |
| #line 560 "compile.y" | #line 567 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LE) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LE) ; |
| break;} | break;} |
| case 147: | case 147: |
| #line 561 "compile.y" | #line 568 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GE) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GE) ; |
| break;} | break;} |
| case 148: | case 148: |
| #line 562 "compile.y" | #line 569 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_EQ) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_EQ) ; |
| break;} | break;} |
| case 149: | case 149: |
| #line 563 "compile.y" | #line 570 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_NE) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_NE) ; |
| break;} | break;} |
| case 150: | case 150: |
| #line 564 "compile.y" | #line 571 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LT) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LT) ; |
| break;} | break;} |
| case 151: | case 151: |
| #line 565 "compile.y" | #line 572 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GT) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GT) ; |
| break;} | break;} |
| case 152: | case 152: |
| #line 566 "compile.y" | #line 573 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LE) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LE) ; |
| break;} | break;} |
| case 153: | case 153: |
| #line 567 "compile.y" | #line 574 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GE) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GE) ; |
| break;} | break;} |
| case 154: | case 154: |
| #line 568 "compile.y" | #line 575 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_EQ) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_EQ) ; |
| break;} | break;} |
| case 155: | case 155: |
| #line 569 "compile.y" | #line 576 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_NE) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_NE) ; |
| break;} | break;} |
| case 156: | case 156: |
| #line 570 "compile.y" | #line 577 "compile.y" |
| { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_IS) ; | { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_IS) ; |
| break;} | break;} |
| case 157: | case 157: |
| #line 573 "compile.y" | #line 580 "compile.y" |
| { | { |
| yyval=N(); | yyval=N(); |
| OA(*yyval, OP_STRING_POOL, yyvsp[0]); /* stack: empty write context */ | OA(*yyval, OP_STRING_POOL, yyvsp[0]); /* stack: empty write context */ |
| Line 1653 case 157: | Line 1660 case 157: |
| ; | ; |
| break;} | break;} |
| case 158: | case 158: |
| #line 582 "compile.y" | #line 589 "compile.y" |
| { | { |
| // optimized from OP_STRING+OP_WRITE_VALUE to OP_STRING__WRITE | // optimized from OP_STRING+OP_WRITE_VALUE to OP_STRING__WRITE |
| change_string_literal_to_write_string_literal(*(yyval=yyvsp[0])) | change_string_literal_to_write_string_literal(*(yyval=yyvsp[0])) |
| ; | ; |
| break;} | break;} |
| case 159: | case 159: |
| #line 587 "compile.y" | #line 594 "compile.y" |
| { yyval=VL(ValuePtr(new VVoid())) ; | { yyval=VL(new VVoid(), 0, 0, 0) ; |
| break;} | break;} |
| case 160: | case 160: |
| #line 588 "compile.y" | #line 595 "compile.y" |
| { yyval=N() ; | { yyval=N() ; |
| break;} | break;} |
| } | } |
| Line 1889 yyerrhandle: | Line 1896 yyerrhandle: |
| } | } |
| return 1; | return 1; |
| } | } |
| #line 590 "compile.y" | #line 597 "compile.y" |
| #endif | #endif |
| Line 1909 yyerrhandle: | Line 1916 yyerrhandle: |
| 4:[^({]=pop | 4:[^({]=pop |
| */ | */ |
| static int yylex(YYSTYPE *lvalp, void *pc) { | inline void ungetc(Parse_control& pc, uint last_line_end_col) { |
| #define lexical_brackets_nestage PC.brackets_nestages[PC.ls_sp] | 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<Parse_control*>(apc); | |
| #define lexical_brackets_nestage pc.brackets_nestages[pc.ls_sp] | |
| #define RC {result=c; goto break2; } | #define RC {result=c; goto break2; } |
| register int c; | register int c; |
| int result; | int result; |
| if(PC.pending_state) { | if(pc.pending_state) { |
| result=PC.pending_state; | result=pc.pending_state; |
| PC.pending_state=0; | pc.pending_state=0; |
| return result; | return result; |
| } | } |
| const char *begin=PC.source; | const char *begin=pc.source; |
| Pos begin_pos=pc.pos; | |
| const char *end; | const char *end; |
| int begin_line=PC.line; | |
| int skip_analized=0; | int skip_analized=0; |
| while(true) { | while(true) { |
| c=*(end=(PC.source++)); | c=*(end=(pc.source++)); |
| // fprintf(stderr, "\nchar: %c %02X; nestage: %d, sp=%d", c, c, lexical_brackets_nestage, PC.sp); | // fprintf(stderr, "\nchar: %c %02X; nestage: %d, sp=%d", c, c, lexical_brackets_nestage, pc.sp); |
| if(c=='\n') { | if(c=='\n') { |
| PC.line++; | pc.pos_next_line(); |
| PC.col=0; | |
| } else | } else |
| PC.col++; | pc.pos_next_c(c); |
| if(c=='@' && PC.col==0+1) { | if(c=='@' && pc.pos.col==0+1) { |
| if(PC.ls==LS_DEF_SPECIAL_BODY) { | if(pc.ls==LS_DEF_SPECIAL_BODY) { |
| // @SPECIAL | // @SPECIAL |
| // ... | // ... |
| // @<here = | // @<here = |
| pop_LS(PC); // exiting from LS_DEF_SPECIAL_BODY state | pop_LS(pc); // exiting from LS_DEF_SPECIAL_BODY state |
| } // continuing checks | } // continuing checks |
| if(PC.ls==LS_USER) { | if(pc.ls==LS_USER) { |
| push_LS(PC, LS_DEF_NAME); | push_LS(pc, LS_DEF_NAME); |
| RC; | RC; |
| } else // @ in first column inside some code [when could that be?] | } else // @ in first column inside some code [when could that be?] |
| result=BAD_METHOD_DECL_START; | result=BAD_METHOD_DECL_START; |
| goto break2; | goto break2; |
| } else if(c=='^') { | } else if(c=='^') { |
| if(PC.ls==LS_METHOD_AFTER) { | if(pc.ls==LS_METHOD_AFTER) { |
| // handle after-method situation | // handle after-method situation |
| pop_LS(PC); | pop_LS(pc); |
| result=EON; | result=EON; |
| skip_analized=-1; // return to punctuation afterwards to assure it's literality | skip_analized=-1; // return to punctuation afterwards to assure it's literality |
| goto break2; | goto break2; |
| } | } |
| switch(PC.ls) { | switch(pc.ls) { |
| case LS_EXPRESSION_VAR_NAME_WITH_COLON: | case LS_EXPRESSION_VAR_NAME_WITH_COLON: |
| case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON: | case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON: |
| case LS_VAR_NAME_SIMPLE_WITH_COLON: | case LS_VAR_NAME_SIMPLE_WITH_COLON: |
| Line 1969 case LS_DEF_COMMENT: | Line 1985 case LS_DEF_COMMENT: |
| // no literals in names, please | // no literals in names, please |
| break; | break; |
| default: | default: |
| switch(*PC.source) { | switch(*pc.source) { |
| // ^escaping some punctuators | // ^escaping some punctuators |
| case '^': case '$': case ';': | case '^': case '$': case ';': |
| case '(': case ')': | case '(': case ')': |
| Line 1977 default: | Line 1993 default: |
| case '{': case '}': | case '{': case '}': |
| case '"': case ':': | case '"': case ':': |
| if(end!=begin) { | if(end!=begin) { |
| if(!pc.string_start) | |
| pc.string_start=begin_pos; | |
| // append piece till ^ | // append piece till ^ |
| PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); | pc.string.append_strdup(begin, end-begin); |
| } | } |
| // reset piece 'begin' position & line | // reset piece 'begin' position & line |
| begin=PC.source; // ->punctuation | begin=pc.source; // ->punctuation |
| begin_line=PC.line; | begin_pos=pc.pos; |
| // skip over _ after ^ | // skip over _ after ^ |
| PC.source++; PC.col++; | pc.source++; pc.pos.col++; |
| // skip analysis = forced literal | // skip analysis = forced literal |
| continue; | continue; |
| // converting ^#HH into char(hex(HH)) | // converting ^#HH into char(hex(HH)) |
| case '#': | case '#': |
| if(end!=begin) { | if(end!=begin) { |
| if(!pc.string_start) | |
| pc.string_start=begin_pos; | |
| // append piece till ^ | // append piece till ^ |
| PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); | pc.string.append_strdup(begin, end-begin); |
| } | } |
| // #HH ? | // #HH ? |
| if(PC.source[0]=='#' && PC.source[1] && PC.source[2]) { | if(pc.source[0]=='#' && pc.source[1] && pc.source[2]) { |
| char *hex=(char *)POOL.malloc(1); | char c= |
| hex[0]= | hex_value[(unsigned char)pc.source[1]]*0x10+ |
| hex_value[(unsigned char)PC.source[1]]*0x10+ | hex_value[(unsigned char)pc.source[2]]; |
| hex_value[(unsigned char)PC.source[2]]; | if(c==0) { |
| if(hex[0]==0) { | |
| result=BAD_HEX_LITERAL; | result=BAD_HEX_LITERAL; |
| goto break2; // wrong hex value[no ^#00 chars allowed]: bail out | goto break2; // wrong hex value[no ^#00 chars allowed]: bail out |
| } | } |
| // append char(hex(HH)) | // append char(hex(HH)) |
| PC.string->APPEND_CLEAN(hex, 1, PC.file, begin_line); | pc.string.append(c); |
| // skip over ^#HH | // skip over ^#HH |
| PC.source+=3; | pc.source+=3; |
| PC.col+=3; | pc.pos.col+=3; |
| // reset piece 'begin' position & line | // reset piece 'begin' position & line |
| begin=PC.source; // ->after ^#HH | begin=pc.source; // ->after ^#HH |
| begin_line=PC.line; | begin_pos=pc.pos; |
| // skip analysis = forced literal | // skip analysis = forced literal |
| continue; | continue; |
| } | } |
| Line 2021 default: | Line 2040 default: |
| } | } |
| } | } |
| // #comment start skipping | // #comment start skipping |
| if(c=='#' && PC.col==1) { | if(c=='#' && pc.pos.col==1) { |
| if(end!=begin) { | if(end!=begin) { |
| if(!pc.string_start) | |
| pc.string_start=begin_pos; | |
| // append piece till # | // append piece till # |
| PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); | pc.string.append_strdup(begin, end-begin); |
| } | } |
| // fall into COMMENT lexical state [wait for \n] | // fall into COMMENT lexical state [wait for \n] |
| push_LS(PC, LS_USER_COMMENT); | push_LS(pc, LS_USER_COMMENT); |
| continue; | continue; |
| } | } |
| switch(PC.ls) { | switch(pc.ls) { |
| // USER'S = NOT OURS | // USER'S = NOT OURS |
| case LS_USER: | case LS_USER: |
| case LS_NAME_SQUARE_PART: // name.[here].xxx | case LS_NAME_SQUARE_PART: // name.[here].xxx |
| if(PC.trim_bof) | if(pc.trim_bof) |
| switch(c) { | switch(c) { |
| case '\n': case ' ': case '\t': | case '\n': case ' ': case '\t': |
| begin=PC.source; | begin=pc.source; |
| begin_line=PC.line; | begin_pos=pc.pos; |
| continue; // skip it | continue; // skip it |
| default: | default: |
| PC.trim_bof=false; | pc.trim_bof=false; |
| } | } |
| switch(c) { | switch(c) { |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); | push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(pc, LS_METHOD_NAME); |
| RC; | RC; |
| case ']': | case ']': |
| if(PC.ls==LS_NAME_SQUARE_PART) | if(pc.ls==LS_NAME_SQUARE_PART) |
| if(--lexical_brackets_nestage==0) {// $name.[co<]?>de<]?> | if(--lexical_brackets_nestage==0) {// $name.[co<]?>de<]?> |
| pop_LS(PC); // $name.[co<]>de<]!> | pop_LS(pc); // $name.[co<]>de<]!> |
| RC; | RC; |
| } | } |
| break; | break; |
| case '[': // $name.[co<[>de] | case '[': // $name.[co<[>de] |
| if(PC.ls==LS_NAME_SQUARE_PART) | if(pc.ls==LS_NAME_SQUARE_PART) |
| lexical_brackets_nestage++; | lexical_brackets_nestage++; |
| break; | break; |
| } | } |
| Line 2069 default: | Line 2090 default: |
| case LS_USER_COMMENT: | case LS_USER_COMMENT: |
| if(c=='\n') { | if(c=='\n') { |
| // skip comment | // skip comment |
| begin=PC.source; | begin=pc.source; |
| begin_line=PC.line; | begin_pos=pc.pos; |
| pop_LS(PC); | pop_LS(pc); |
| continue; | continue; |
| } | } |
| break; | break; |
| Line 2084 default: | Line 2105 default: |
| case '"': | case '"': |
| case '\'': | case '\'': |
| if( | if( |
| PC.ls == LS_EXPRESSION_STRING_QUOTED && c=='"' || | pc.ls == LS_EXPRESSION_STRING_QUOTED && c=='"' || |
| PC.ls == LS_EXPRESSION_STRING_APOSTROFED && c=='\'') { | pc.ls == LS_EXPRESSION_STRING_APOSTROFED && c=='\'') { |
| pop_LS(PC); //"abc". | 'abc'. | pop_LS(pc); //"abc". | 'abc'. |
| RC; | RC; |
| } | } |
| break; | break; |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); | push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(pc, LS_METHOD_NAME); |
| RC; | RC; |
| } | } |
| break; | break; |
| Line 2103 default: | Line 2124 default: |
| case LS_DEF_NAME: | case LS_DEF_NAME: |
| switch(c) { | switch(c) { |
| case '[': | case '[': |
| PC.ls=LS_DEF_PARAMS; | pc.ls=LS_DEF_PARAMS; |
| RC; | RC; |
| case '\n': | case '\n': |
| PC.ls=LS_DEF_SPECIAL_BODY; | pc.ls=LS_DEF_SPECIAL_BODY; |
| RC; | RC; |
| } | } |
| break; | break; |
| Line 2119 default: | Line 2140 default: |
| case ';': | case ';': |
| RC; | RC; |
| case ']': | case ']': |
| PC.ls=*PC.source=='['?LS_DEF_LOCALS:LS_DEF_COMMENT; | pc.ls=*pc.source=='['?LS_DEF_LOCALS:LS_DEF_COMMENT; |
| RC; | RC; |
| case '\n': // wrong. bailing out | case '\n': // wrong. bailing out |
| pop_LS(PC); | pop_LS(pc); |
| RC; | RC; |
| } | } |
| break; | break; |
| Line 2133 default: | Line 2154 default: |
| case ';': | case ';': |
| RC; | RC; |
| case ']': | case ']': |
| PC.ls=LS_DEF_COMMENT; | pc.ls=LS_DEF_COMMENT; |
| RC; | RC; |
| case '\n': // wrong. bailing out | case '\n': // wrong. bailing out |
| pop_LS(PC); | pop_LS(pc); |
| RC; | RC; |
| } | } |
| break; | break; |
| case LS_DEF_COMMENT: | case LS_DEF_COMMENT: |
| if(c=='\n') { | if(c=='\n') { |
| pop_LS(PC); | pop_LS(pc); |
| RC; | RC; |
| } | } |
| break; | break; |
| Line 2159 default: | Line 2180 default: |
| switch(c) { | switch(c) { |
| case ')': | case ')': |
| if(--lexical_brackets_nestage==0) | if(--lexical_brackets_nestage==0) |
| if(PC.ls==LS_METHOD_ROUND) // method round param ended | if(pc.ls==LS_METHOD_ROUND) // method round param ended |
| PC.ls=LS_METHOD_AFTER; // look for method end | pc.ls=LS_METHOD_AFTER; // look for method end |
| else // PC.ls==LS_VAR_ROUND // variable constructor ended | else // pc.ls==LS_VAR_ROUND // variable constructor ended |
| pop_LS(PC); // return to normal life | pop_LS(pc); // return to normal life |
| RC; | RC; |
| case '#': // comment start skipping | case '#': // comment start skipping |
| if(end!=begin) { | if(end!=begin) { |
| if(!pc.string_start) | |
| pc.string_start=begin_pos; | |
| // append piece till # | // append piece till # |
| PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); | pc.string.append_strdup(begin, end-begin); |
| } | } |
| // fall into COMMENT lexical state [wait for \n] | // fall into COMMENT lexical state [wait for \n] |
| push_LS(PC, LS_EXPRESSION_COMMENT); | push_LS(pc, LS_EXPRESSION_COMMENT); |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| continue; | continue; |
| case '$': | case '$': |
| push_LS(PC, LS_EXPRESSION_VAR_NAME_WITH_COLON); | push_LS(pc, LS_EXPRESSION_VAR_NAME_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(pc, LS_METHOD_NAME); |
| RC; | RC; |
| case '(': | case '(': |
| lexical_brackets_nestage++; | lexical_brackets_nestage++; |
| RC; | RC; |
| case '-': | case '-': |
| switch(*PC.source) { | switch(*pc.source) { |
| case 'f': // -f | case 'f': // -f |
| skip_analized=1; | skip_analized=1; |
| result=FEXISTS; | result=FEXISTS; |
| Line 2202 default: | Line 2225 default: |
| case ';': | case ';': |
| RC; | RC; |
| case '&': case '|': | case '&': case '|': |
| if(*PC.source==c) { // && || | if(*pc.source==c) { // && || |
| result=c=='&'?LAND:LOR; | result=c=='&'?LAND:LOR; |
| skip_analized=1; | skip_analized=1; |
| } else | } else |
| result=c; | result=c; |
| goto break2; | goto break2; |
| case '!': | case '!': |
| switch(PC.source[0]) { | switch(pc.source[0]) { |
| case '|': // !| !|| | case '|': // !| !|| |
| skip_analized=1; | skip_analized=1; |
| if(PC.source[1]=='|') { | if(pc.source[1]=='|') { |
| skip_analized++; | skip_analized++; |
| result=LXOR; | result=LXOR; |
| } else | } else |
| Line 2226 default: | Line 2249 default: |
| RC; | RC; |
| case '<': // <<, <=, < | case '<': // <<, <=, < |
| switch(*PC.source) { | switch(*pc.source) { |
| case '<': // <[<] | case '<': // <[<] |
| skip_analized=1; result=NSL; break; | skip_analized=1; result=NSL; break; |
| case '=': // <[=] | case '=': // <[=] |
| Line 2236 default: | Line 2259 default: |
| } | } |
| goto break2; | goto break2; |
| case '>': // >>, >=, > | case '>': // >>, >=, > |
| switch(*PC.source) { | switch(*pc.source) { |
| case '>': // >[>] | case '>': // >[>] |
| skip_analized=1; result=NSR; break; | skip_analized=1; result=NSR; break; |
| case '=': // >[=] | case '=': // >[=] |
| Line 2246 default: | Line 2269 default: |
| } | } |
| goto break2; | goto break2; |
| case '=': // == | case '=': // == |
| switch(*PC.source) { | switch(*pc.source) { |
| case '=': // =[=] | case '=': // =[=] |
| skip_analized=1; result=NEQ; break; | skip_analized=1; result=NEQ; break; |
| default: // =[] | default: // =[] |
| Line 2255 default: | Line 2278 default: |
| goto break2; | goto break2; |
| case '"': | case '"': |
| push_LS(PC, LS_EXPRESSION_STRING_QUOTED); | push_LS(pc, LS_EXPRESSION_STRING_QUOTED); |
| RC; | RC; |
| case '\'': | case '\'': |
| push_LS(PC, LS_EXPRESSION_STRING_APOSTROFED); | push_LS(pc, LS_EXPRESSION_STRING_APOSTROFED); |
| RC; | RC; |
| case 'l': case 'g': case 'e': case 'n': | case 'l': case 'g': case 'e': case 'n': |
| if(end==begin) // right after whitespace | if(end==begin) // right after whitespace |
| if(isspace(PC.source[1])) { | if(isspace(pc.source[1])) { |
| switch(*PC.source) { | switch(*pc.source) { |
| // case '?': // ok [and bad cases, yacc would bark at them] | // case '?': // ok [and bad cases, yacc would bark at them] |
| case 't': // lt gt [et nt] | case 't': // lt gt [et nt] |
| result=c=='l'?SLT:c=='g'?SGT:BAD_STRING_COMPARISON_OPERATOR; | result=c=='l'?SLT:c=='g'?SGT:BAD_STRING_COMPARISON_OPERATOR; |
| Line 2282 default: | Line 2305 default: |
| break; | break; |
| case 'i': | case 'i': |
| if(end==begin) // right after whitespace | if(end==begin) // right after whitespace |
| if(isspace(PC.source[1])) { | if(isspace(pc.source[1])) { |
| switch(PC.source[0]) { | switch(pc.source[0]) { |
| case 'n': // in | case 'n': // in |
| skip_analized=1; | skip_analized=1; |
| result=IN; | result=IN; |
| Line 2297 default: | Line 2320 default: |
| break; | break; |
| case 'd': | case 'd': |
| if(end==begin) // right after whitespace | if(end==begin) // right after whitespace |
| if(PC.source[0]=='e' && PC.source[1]=='f') { // def | if(pc.source[0]=='e' && pc.source[1]=='f') { // def |
| skip_analized=2; | skip_analized=2; |
| result=DEF; | result=DEF; |
| goto break2; | goto break2; |
| Line 2311 default: | Line 2334 default: |
| // that's a leading|traling space or after-operator-space | // that's a leading|traling space or after-operator-space |
| // ignoring it | // ignoring it |
| // reset piece 'begin' position & line | // reset piece 'begin' position & line |
| begin=PC.source; // after whitespace char | begin=pc.source; // after whitespace char |
| begin_line=PC.line; | begin_pos=pc.pos; |
| continue; | continue; |
| } | } |
| break; | break; |
| Line 2320 default: | Line 2343 default: |
| if(c=='(') | if(c=='(') |
| lexical_brackets_nestage++; | lexical_brackets_nestage++; |
| switch(*PC.source) { | switch(*pc.source) { |
| case '\n': case ')': | case '\n': case ')': |
| if(*PC.source==')') | if(*pc.source==')') |
| if(--lexical_brackets_nestage!=0) | if(--lexical_brackets_nestage!=0) |
| continue; | continue; |
| // skip comment | // skip comment |
| begin=PC.source; | begin=pc.source; |
| begin_line=PC.line; | begin_pos=pc.pos; |
| pop_LS(PC); | pop_LS(pc); |
| continue; | continue; |
| } | } |
| break; | break; |
| Line 2341 default: | Line 2364 default: |
| case LS_EXPRESSION_VAR_NAME_WITH_COLON: | case LS_EXPRESSION_VAR_NAME_WITH_COLON: |
| case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON: | case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON: |
| if( | if( |
| PC.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON || | pc.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON || |
| PC.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) { | pc.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) { |
| // name in expr ends also before | // name in expr ends also before |
| switch(c) { | switch(c) { |
| // expression minus | // expression minus |
| case '-': | case '-': |
| // expression integer division | // expression integer division |
| case '\\': | case '\\': |
| pop_LS(PC); | pop_LS(pc); |
| PC.source--; if(--PC.col<0) { PC.line--; PC.col=-1; } | pc.ungetc(); |
| result=EON; | result=EON; |
| goto break2; | goto break2; |
| } | } |
| } | } |
| if( | if( |
| PC.ls==LS_VAR_NAME_SIMPLE_WITHOUT_COLON || | pc.ls==LS_VAR_NAME_SIMPLE_WITHOUT_COLON || |
| PC.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) { | pc.ls==LS_EXPRESSION_VAR_NAME_WITHOUT_COLON) { |
| // name already has ':', stop before next | // name already has ':', stop before next |
| switch(c) { | switch(c) { |
| case ':': | case ':': |
| pop_LS(PC); | pop_LS(pc); |
| PC.source--; if(--PC.col<0) { PC.line--; PC.col=-1; } | pc.ungetc(); |
| result=EON; | result=EON; |
| goto break2; | goto break2; |
| } | } |
| Line 2381 default: | Line 2404 default: |
| case ',': case '?': case '#': | case ',': case '?': case '#': |
| // before call | // before call |
| case '^': | case '^': |
| pop_LS(PC); | pop_LS(pc); |
| PC.source--; if(--PC.col<0) { PC.line--; PC.col=-1; } | pc.ungetc(); |
| result=EON; | result=EON; |
| goto break2; | goto break2; |
| case '[': | case '[': |
| // $name.<[>code] | // $name.<[>code] |
| if(PC.col>1/*not first column*/ && ( | if(pc.pos.col>1/*not first column*/ && ( |
| end[-1]=='$'/*was start of get*/ || | end[-1]=='$'/*was start of get*/ || |
| end[-1]==':'/*was class name delim */ || | end[-1]==':'/*was class name delim */ || |
| end[-1]=='.'/*was name delim */ | end[-1]=='.'/*was name delim */ |
| )) { | )) { |
| push_LS(PC, LS_NAME_SQUARE_PART); | push_LS(pc, LS_NAME_SQUARE_PART); |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| } | } |
| PC.ls=LS_VAR_SQUARE; | pc.ls=LS_VAR_SQUARE; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| case '{': | case '{': |
| if(begin==end) { // ${name}, no need of EON, switching LS | if(begin==end) { // ${name}, no need of EON, switching LS |
| PC.ls=LS_VAR_NAME_CURLY; | pc.ls=LS_VAR_NAME_CURLY; |
| } else { | } else { |
| PC.ls=LS_VAR_CURLY; | pc.ls=LS_VAR_CURLY; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| } | } |
| RC; | RC; |
| case '(': | case '(': |
| PC.ls=LS_VAR_ROUND; | pc.ls=LS_VAR_ROUND; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| case '.': // name part delim | case '.': // name part delim |
| case '$': // name part subvar | case '$': // name part subvar |
| case ':': // class<:>name | case ':': // class<:>name |
| // go to _WITHOUT_COLON state variant... | // go to _WITHOUT_COLON state variant... |
| if(PC.ls==LS_VAR_NAME_SIMPLE_WITH_COLON) | if(pc.ls==LS_VAR_NAME_SIMPLE_WITH_COLON) |
| PC.ls=LS_VAR_NAME_SIMPLE_WITHOUT_COLON; | pc.ls=LS_VAR_NAME_SIMPLE_WITHOUT_COLON; |
| else if(PC.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON) | else if(pc.ls==LS_EXPRESSION_VAR_NAME_WITH_COLON) |
| PC.ls=LS_EXPRESSION_VAR_NAME_WITHOUT_COLON; | pc.ls=LS_EXPRESSION_VAR_NAME_WITHOUT_COLON; |
| // ...stop before next ':' | // ...stop before next ':' |
| RC; | RC; |
| } | } |
| Line 2429 default: | Line 2452 default: |
| switch(c) { | switch(c) { |
| case '[': | case '[': |
| // ${name.<[>code]} | // ${name.<[>code]} |
| push_LS(PC, LS_NAME_SQUARE_PART); | push_LS(pc, LS_NAME_SQUARE_PART); |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| case '}': // ${name} finished, restoring LS | case '}': // ${name} finished, restoring LS |
| pop_LS(PC); | pop_LS(pc); |
| RC; | RC; |
| case '.': // name part delim | case '.': // name part delim |
| case '$': // name part subvar | case '$': // name part subvar |
| Line 2445 default: | Line 2468 default: |
| case LS_VAR_SQUARE: | case LS_VAR_SQUARE: |
| switch(c) { | switch(c) { |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); | push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(pc, LS_METHOD_NAME); |
| RC; | RC; |
| case ']': | case ']': |
| if(--lexical_brackets_nestage==0) { | if(--lexical_brackets_nestage==0) { |
| pop_LS(PC); | pop_LS(pc); |
| RC; | RC; |
| } | } |
| break; | break; |
| Line 2467 default: | Line 2490 default: |
| case LS_VAR_CURLY: | case LS_VAR_CURLY: |
| switch(c) { | switch(c) { |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); | push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(pc, LS_METHOD_NAME); |
| RC; | RC; |
| case '}': | case '}': |
| if(--lexical_brackets_nestage==0) { | if(--lexical_brackets_nestage==0) { |
| pop_LS(PC); | pop_LS(pc); |
| RC; | RC; |
| } | } |
| break; | break; |
| Line 2489 default: | Line 2512 default: |
| switch(c) { | switch(c) { |
| case '[': | case '[': |
| // ^name.<[>code].xxx | // ^name.<[>code].xxx |
| if(PC.col>1/*not first column*/ && ( | if(pc.pos.col>1/*not first column*/ && ( |
| end[-1]=='^'/*was start of call*/ || // never, ^[ is literal... | end[-1]=='^'/*was start of call*/ || // never, ^[ is literal... |
| end[-1]==':'/*was class name delim */ || | end[-1]==':'/*was class name delim */ || |
| end[-1]=='.'/*was name delim */ | end[-1]=='.'/*was name delim */ |
| )) { | )) { |
| push_LS(PC, LS_NAME_SQUARE_PART); | push_LS(pc, LS_NAME_SQUARE_PART); |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| } | } |
| PC.ls=LS_METHOD_SQUARE; | pc.ls=LS_METHOD_SQUARE; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| case '{': | case '{': |
| PC.ls=LS_METHOD_CURLY; | pc.ls=LS_METHOD_CURLY; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| case '(': | case '(': |
| PC.ls=LS_METHOD_ROUND; | pc.ls=LS_METHOD_ROUND; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| case '.': // name part delim | case '.': // name part delim |
| Line 2521 default: | Line 2544 default: |
| case LS_METHOD_SQUARE: | case LS_METHOD_SQUARE: |
| switch(c) { | switch(c) { |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); | push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(pc, LS_METHOD_NAME); |
| RC; | RC; |
| case ';': // param delim | case ';': // param delim |
| RC; | RC; |
| case ']': | case ']': |
| if(--lexical_brackets_nestage==0) { | if(--lexical_brackets_nestage==0) { |
| PC.ls=LS_METHOD_AFTER; | pc.ls=LS_METHOD_AFTER; |
| RC; | RC; |
| } | } |
| break; | break; |
| Line 2543 default: | Line 2566 default: |
| case LS_METHOD_CURLY: | case LS_METHOD_CURLY: |
| switch(c) { | switch(c) { |
| case '$': | case '$': |
| push_LS(PC, LS_VAR_NAME_SIMPLE_WITH_COLON); | push_LS(pc, LS_VAR_NAME_SIMPLE_WITH_COLON); |
| RC; | RC; |
| case '^': | case '^': |
| push_LS(PC, LS_METHOD_NAME); | push_LS(pc, LS_METHOD_NAME); |
| RC; | RC; |
| case ';': // param delim | case ';': // param delim |
| RC; | RC; |
| case '}': | case '}': |
| if(--lexical_brackets_nestage==0) { | if(--lexical_brackets_nestage==0) { |
| PC.ls=LS_METHOD_AFTER; | pc.ls=LS_METHOD_AFTER; |
| RC; | RC; |
| } | } |
| break; | break; |
| Line 2564 default: | Line 2587 default: |
| case LS_METHOD_AFTER: | case LS_METHOD_AFTER: |
| if(c=='[') {/* ][ }[ )[ */ | if(c=='[') {/* ][ }[ )[ */ |
| PC.ls=LS_METHOD_SQUARE; | pc.ls=LS_METHOD_SQUARE; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| } | } |
| if(c=='{') {/* ]{ }{ ){ */ | if(c=='{') {/* ]{ }{ ){ */ |
| PC.ls=LS_METHOD_CURLY; | pc.ls=LS_METHOD_CURLY; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| } | } |
| if(c=='(') {/* ]( }( )( */ | if(c=='(') {/* ]( }( )( */ |
| PC.ls=LS_METHOD_ROUND; | pc.ls=LS_METHOD_ROUND; |
| lexical_brackets_nestage=1; | lexical_brackets_nestage=1; |
| RC; | RC; |
| } | } |
| pop_LS(PC); | pop_LS(pc); |
| PC.source--; if(--PC.col<0) { PC.line--; PC.col=-1; } | pc.ungetc(); |
| result=EON; | result=EON; |
| goto break2; | goto break2; |
| } | } |
| Line 2597 break2: | Line 2620 break2: |
| if(end!=begin && end[-1]=='\n') // allow one empty line before LS_DEF_NAME | if(end!=begin && end[-1]=='\n') // allow one empty line before LS_DEF_NAME |
| end--; | end--; |
| } | } |
| if(end!=begin && PC.ls!=LS_USER_COMMENT) { // last piece still alive and not comment? | if(end!=begin && pc.ls!=LS_USER_COMMENT) { // last piece still alive and not comment? |
| if(!pc.string_start) | |
| pc.string_start=begin_pos; | |
| // append it | // append it |
| PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line/*, start_col*/); | pc.string.append_strdup(begin, end-begin); |
| } | } |
| } | } |
| if(PC.string->size()) { // something accumulated? | 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(ValuePtr(new VString(PC.string))); | *lvalp=VL( |
| new VString(*new String(pc.string, String::L_CLEAN)), | |
| pc.file_no, pc.string_start.line, pc.string_start.col); | |
| // new pieces storage | // new pieces storage |
| PC.string=StringPtr(new String); | pc.string.clear(); |
| pc.string_start.clear(); | |
| // make current result be pending for next call, return STRING for now | // make current result be pending for next call, return STRING for now |
| PC.pending_state=result; result=STRING; | pc.pending_state=result; result=STRING; |
| } | } |
| if(skip_analized) { | if(skip_analized) { |
| PC.source+=skip_analized; PC.col+=skip_analized; | pc.source+=skip_analized; pc.pos.col+=skip_analized; |
| } | } |
| return result; | return result; |
| } | } |
| static int real_yyerror(parse_control *pc, char *s) { // Called by yyparse on error | static int real_yyerror(Parse_control *pc, char *s) { // Called by yyparse on error |
| strncpy(PC.error, s, MAX_STRING); | strncpy(PC.error, s, MAX_STRING); |
| return 1; | return 1; |
| } | } |