--- parser3/src/main/compile.y 2001/03/30 05:52:17 1.122 +++ parser3/src/main/compile.y 2001/04/20 14:18:41 1.126 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.y,v 1.122 2001/03/30 05:52:17 paf Exp $ + $Id: compile.y,v 1.126 2001/04/20 14:18:41 paf Exp $ */ /** @@ -44,9 +44,9 @@ #define SELF_ELEMENT_NAME "self" #define USE_CONTROL_METHOD_NAME "USE" -int real_yyerror(parse_control *pc, char *s); +static int real_yyerror(parse_control *pc, char *s); static void yyprint(FILE *file, int type, YYSTYPE value); -int yylex(YYSTYPE *lvalp, void *pc); +static int yylex(YYSTYPE *lvalp, void *pc); // local convinient inplace typecast & var @@ -137,7 +137,7 @@ control_method: '@' STRING '\n' YYERROR; } if(command==CLASS_NAME) { - if(PC.cclass!=&PC.request->ROOT) { // already changed from default? + if(PC.cclass) { // already changed from default? strcpy(PC.error, "class already have a name '"); strncat(PC.error, PC.cclass->name().cstr(), 100); strcat(PC.error, "'"); @@ -149,8 +149,6 @@ control_method: '@' STRING '\n' // creating the class PC.cclass=NEW VClass(POOL); PC.cclass->set_name(*name); - // defaulting base. may change with @BASE - PC.cclass->set_base(PC.request->ROOT); // append to request's classes PC.request->classes().put(*name, PC.cclass); } else { @@ -163,7 +161,7 @@ control_method: '@' STRING '\n' PC.request->use_file( PC.request->absolute(*LA2S(strings_code, i))); } else if(command==BASE_NAME) { - if(PC.cclass->base()!=&PC.request->ROOT) { // already changed from default? + if(PC.cclass->base()) { // already changed from default? strcpy(PC.error, "class already have a base '"); strncat(PC.error, PC.cclass->base()->name().cstr(), 100); strcat(PC.error, "'"); @@ -347,8 +345,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; @@ -359,16 +364,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: @@ -583,8 +579,9 @@ static int yylex(YYSTYPE *lvalp, void *p if(c=='^' && PC.ls!=LS_COMMENT && PC.ls!=LS_DEF_COMMENT) switch(*PC.source) { - // escaping: ^^ ^$ ^; ^) ^} ^( ^{ ^" + // escaping: ^^ & co case '^': case '$': case ';': + case '(': case ')': case '[': case ']': case '{': case '}': case '"': @@ -868,13 +865,14 @@ static int yylex(YYSTYPE *lvalp, void *p case 0: case ' ': case '\t': case '\n': case ';': - case ']': case '}': case ')': case '"': + case ']': case '}': case ')': + case '"': case '\'': case '<': case '>': // these stand for HTML brackets and expression binary ops case '+': case '*': case '/': case '%': case '&': case '|': case '=': case '!': // common delimiters - case '\'': case ',': + case ',': pop_LS(PC); PC.source--; if(--PC.col<0) { PC.line--; PC.col=-1; } result=EON;