--- parser3/src/main/compile.y 2001/03/29 09:31:43 1.120 +++ parser3/src/main/compile.y 2001/04/03 17:15:07 1.123 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.y,v 1.120 2001/03/29 09:31:43 paf Exp $ + $Id: compile.y,v 1.123 2001/04/03 17:15:07 paf Exp $ */ /** @@ -113,6 +113,7 @@ all: one_big_piece { Method& method=*NEW Method(POOL, *main_method_name, + Method::CT_ANY, 0, 0, /*min, max numbered_params_count*/ 0/*param_names*/, 0/*local_names*/, $1/*parser_code*/, 0/*native_code*/); @@ -222,6 +223,7 @@ code_method: '@' STRING bracketed_maybe_ Method& method=*NEW Method(POOL, *name, + Method::CT_ANY, 0, 0/*min,max numbered_params_count*/, params_names, locals_names, $7, 0); @@ -345,8 +347,15 @@ call: call_value { call_value: '^' call_name store_params EON { /* ^field.$method{vasya} */ $$=$2; /* with_xxx,diving code; stack: context,method_junction */ O($$, OP_GET_METHOD_FRAME); /* stack: context,method_frame */ - P($$, $3); /* filling method_frame.store_params */ - O($$, OP_CALL); /* method_frame=pop; ncontext=pop; call(ncontext,method_frame) stack: value */ + + YYSTYPE params_code=$3; + if(params_code->size()==3) // probably [] case. [OP_VALUE + Unknown + STORE_PARAM] + if(Value *value=LA2V(params_code)) // it is OP_VALUE + value? + if(!value->is_defined()) // value is VUnknown? + params_code=0; // ^zzz[] case. don't append lone empty param. + if(params_code) + P($$, params_code); // filling method_frame.store_params + O($$, OP_CALL); // method_frame=pop; ncontext=pop; call(ncontext,method_frame) stack: value }; call_name: name_without_curly_rdive; @@ -357,16 +366,7 @@ store_param: | store_round_param | store_curly_param ; -store_square_param: '[' store_code_param_parts ']' { - YYSTYPE params_code=$2; - if(params_code->size()==3) // probably [] case. [OP_VALUE + Unknown + STORE_PARAM] - if(!LA2V(params_code)->is_defined()) { // value is VUnknown? - $$=N(POOL); // ^zzz[] case. don't append lone empty param. - break; - } - - $$=params_code; -}; +store_square_param: '[' store_code_param_parts ']' {$$=$2}; store_round_param: '(' store_expr_param_parts ')' {$$=$2}; store_curly_param: '{' store_curly_param_parts '}' {$$=$2}; store_code_param_parts: @@ -588,7 +588,7 @@ static int yylex(YYSTYPE *lvalp, void *p case '"': if(end!=begin) { // append piece till ^ - PC.string->APPEND(begin, end-begin, PC.file, begin_line); + PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); } // reset piece 'begin' position & line begin=PC.source; // ^ @@ -602,7 +602,7 @@ static int yylex(YYSTYPE *lvalp, void *p case '#': if(end!=begin) { // append piece till ^ - PC.string->APPEND(begin, end-begin, PC.file, begin_line); + PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); } // #HH ? if(PC.source[0]=='#' && PC.source[1] && PC.source[2]) { @@ -615,7 +615,7 @@ static int yylex(YYSTYPE *lvalp, void *p goto break2; // wrong hex value[no ^#00 chars allowed]: bail out } // append char(hex(HH)) - PC.string->APPEND(hex, 1, PC.file, begin_line); + PC.string->APPEND_CLEAN(hex, 1, PC.file, begin_line); // skip over ^#HH PC.source+=3; PC.col+=3; @@ -630,7 +630,7 @@ static int yylex(YYSTYPE *lvalp, void *p if(c=='#' && PC.col==1) { if(end!=begin) { // append piece till # - PC.string->APPEND(begin, end-begin, PC.file, begin_line); + PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); } // fall into COMMENT lexical state [wait for \n] push_LS(PC, LS_COMMENT); @@ -1056,7 +1056,7 @@ break2: } if(end!=begin) { // last piece still alive? // append it - PC.string->APPEND(begin, end-begin, PC.file, begin_line/*, start_col*/); + PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line/*, start_col*/); } } if(PC.string->size()) { // something accumulated?