--- parser3/src/main/compile.y 2001/07/26 10:47:02 1.154 +++ parser3/src/main/compile.y 2001/07/28 12:01:50 1.158 @@ -6,7 +6,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) */ %{ -static char *RCSId="$Id: compile.y,v 1.154 2001/07/26 10:47:02 parser Exp $"; +static char *RCSId="$Id: compile.y,v 1.158 2001/07/28 12:01:50 parser Exp $"; /** @todo parser4: @@ -263,7 +263,7 @@ name_without_curly_rdive_read: name_with } /* diving code; stack: current context */ }; -name_without_curly_rdive_class: class_prefix_get name_without_curly_rdive_code { $$=$1; P($$, $2) }; +name_without_curly_rdive_class: class_prefix name_without_curly_rdive_code { $$=$1; P($$, $2) }; name_without_curly_rdive_code: name_advance2 | name_path name_advance2 { $$=$1; P($$, $2) }; /* put */ @@ -273,9 +273,10 @@ put: '$' name_expr_wdive construct { P($$, $3); /* stack: context,name,constructor_value */ }; name_expr_wdive: - name_expr_wdive_write + name_expr_wdive_root +| name_expr_wdive_write | name_expr_wdive_class; -name_expr_wdive_write: name_expr_dive_code { +name_expr_wdive_root: name_expr_dive_code { $$=N(POOL); Array *diving_code=$1; const String *first_name=LA2S(diving_code); @@ -285,12 +286,17 @@ name_expr_wdive_write: name_expr_dive_co /* skip over... */ diving_code->size()>2?3/*OP_+string+get_element*/:2/*OP_+string*/); } else { - O($$, OP_WITH_WRITE); /* stack: starting context */ + O($$, OP_WITH_ROOT); /* stack: starting context */ P($$, diving_code); } /* diving code; stack: current context */ }; -name_expr_wdive_class: class_prefix_get name_expr_dive_code { $$=$1; P($$, $2) }; +name_expr_wdive_write: '.' name_expr_dive_code { + $$=N(POOL); + O($$, OP_WITH_WRITE); /* stack: starting context */ + P($$, $2); /* diving code; stack: context,name */ +}; +name_expr_wdive_class: class_prefix name_expr_dive_code { $$=$1; P($$, $2) }; construct: construct_square | @@ -316,7 +322,7 @@ construct_curly: '{' maybe_codes '}' { }; any_constructor_code_value: - empty_string_value /* optimized $var[] case */ + void_value /* optimized $var[] case */ | STRING /* optimized $var[STRING] case */ | constructor_code_value /* $var[something complex] */ ; @@ -348,9 +354,7 @@ call_value: '^' { PC.object_constructor_ params_code=0; // ^zzz[] case. don't append lone empty param. if(params_code) P($$, params_code); // filling method_frame.store_params - O($$, - PC.object_constructing?(PC.object_constructing=false),OP_CALL_CONSTRUCTOR: - OP_CALL_METHOD); // method_frame=pop; ncontext=pop; call(ncontext,method_frame) stack: value + O($$, OP_CALL); // method_frame=pop; ncontext=pop; call(ncontext,method_frame) stack: value }; call_name: name_without_curly_rdive; @@ -389,7 +393,7 @@ store_curly_param_part: maybe_codes { PCA($$, $1); }; code_param_value: - empty_void_value /* optimized [;...] case */ + void_value /* optimized [;...] case */ | STRING /* optimized [STRING] case */ | constructor_code_value /* [something complex] */ ; @@ -444,22 +448,21 @@ subvar__get_write: '$' subvar_ref_name_r O($$, OP_GET_ELEMENT__WRITE); }; -class_prefix_get: class_prefix { - $$=$1; // stack: class name string - O($$, OP_GET_CLASS); -}; class_prefix: class_static_prefix | class_constructor_prefix ; -class_static_prefix: STRING ':'; -class_constructor_prefix: STRING ':' ':' { +class_static_prefix: STRING ':' { + $$=$1; // stack: class name string + O($$, OP_GET_CLASS); +}; +class_constructor_prefix: class_static_prefix ':' { $$=$1; if(!PC.object_constructor_allowed) { strcpy(PC.error, ":: not allowed here"); YYERROR; } - PC.object_constructing=true; + O($$, OP_PREPARE_TO_CONSTRUCT_OBJECT); }; @@ -525,8 +528,7 @@ write_string: STRING { change_string_literal_to_write_string_literal($$=$1) }; -empty_void_value: /* empty */ { $$=VL(NEW VVoid(POOL)) }; -empty_string_value: /* empty */ { $$=VL(NEW VString(POOL)) }; +void_value: /* empty */ { $$=VL(NEW VVoid(POOL)) }; empty: /* empty */ { $$=N(POOL) }; %% @@ -912,7 +914,7 @@ static int yylex(YYSTYPE *lvalp, void *p case '&': case '|': case '=': case '!': // common delimiters - case ',': + case ',': case '?': // before call case '^': pop_LS(PC);