--- parser3/src/main/compile.tab.C 2003/04/03 06:16:04 1.81.2.13.2.22 +++ parser3/src/main/compile.tab.C 2003/04/03 15:34:01 1.81.2.13.2.29 @@ -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.22 2003/04/03 06:16:04 paf Exp $ + $Id: compile.tab.C,v 1.81.2.13.2.29 2003/04/03 15:34:01 paf Exp $ */ /** @@ -83,9 +83,9 @@ // 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); +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 @@ -1041,11 +1041,11 @@ yyreduce: case 1: #line 123 "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: @@ -1053,7 +1053,7 @@ case 8: { 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"); @@ -1066,7 +1066,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 @@ -1080,7 +1080,7 @@ case 8: 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? @@ -1089,7 +1089,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 @@ -1135,7 +1135,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: @@ -1193,19 +1193,19 @@ case 42: 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 */ @@ -1233,12 +1233,12 @@ case 50: 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); @@ -1324,8 +1324,8 @@ case 69: 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. } @@ -1917,7 +1917,7 @@ yyerrhandle: 4:[^({]=pop */ -inline ungetc(Parse_control& pc, uint last_line_end_col) { +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; @@ -1942,7 +1942,6 @@ static int yylex(YYSTYPE *lvalp, void *a const char *begin=pc.source; Pos begin_pos=pc.pos; - uint last_line_end_col=0; const char *end; int skip_analized=0; while(true) { @@ -1950,9 +1949,7 @@ 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++; - last_line_end_col=pc.pos.col; - pc.pos.col=0; + pc.pos_next_line(); } else pc.pos.col+=c=='\t'?TAB_SIZE:1; @@ -2377,7 +2374,7 @@ default: // expression integer division case '\\': pop_LS(pc); - ungetc(pc, last_line_end_col); + pc.ungetc(); result=EON; goto break2; } @@ -2389,7 +2386,7 @@ default: switch(c) { case ':': pop_LS(pc); - ungetc(pc, last_line_end_col); + pc.ungetc(); result=EON; goto break2; } @@ -2409,7 +2406,7 @@ default: // before call case '^': pop_LS(pc); - ungetc(pc, last_line_end_col); + pc.ungetc(); result=EON; goto break2; case '[': @@ -2606,7 +2603,7 @@ default: RC; } pop_LS(pc); - ungetc(pc, last_line_end_col); + pc.ungetc(); result=EON; goto break2; } @@ -2632,7 +2629,7 @@ break2: } } 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);