--- parser3/src/main/compile.y 2001/10/31 13:07:35 1.173 +++ parser3/src/main/compile.y 2002/01/31 17:12:04 1.178 @@ -5,7 +5,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.y,v 1.173 2001/10/31 13:07:35 paf Exp $ + $Id: compile.y,v 1.178 2002/01/31 17:12:04 paf Exp $ */ /** @@ -341,8 +341,14 @@ call: call_value { $$=$1; /* stack: value */ O($$, OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */ }; -call_value: '^' { PC.object_constructor_allowed=true } - call_name { PC.object_constructor_allowed=false } +call_value: '^' { + PC.object_constructor_allowed=true; + push_OCA(PC, true); + } + call_name { + PC.object_constructor_allowed=false; + pop_OCA(PC); + } store_params EON { /* ^field.$method{vasya} */ $$=$3; /* with_xxx,diving code; stack: context,method_junction */ O($$, OP_GET_METHOD_FRAME); /* stack: context,method_frame */ @@ -409,6 +415,9 @@ name_expr_dive_code: name_expr_value | n name_path: name_step | name_path name_step { $$=$1; P($$, $2) }; name_step: name_advance1 '.'; name_advance1: name_expr_value { + // 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 + /* stack: context */ $$=$1; /* stack: context,name */ O($$, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */ @@ -416,7 +425,9 @@ name_advance1: name_expr_value { name_advance2: name_expr_value { /* stack: context */ $$=$1; /* stack: context,name */ - O($$, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */ + O($$, PC.operator_call_allowed?OP_GET_ELEMENT_OR_OPERATOR:OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */ + // only ^FIRST.part.allowed.to.be.an.operator + PC.operator_call_allowed=false; } | STRING BOGUS ; @@ -460,6 +471,9 @@ class_prefix: | class_constructor_prefix ; class_static_prefix: STRING ':' { + // drop allow code after "name:" + PC.operator_call_allowed=false; + $$=$1; // stack: class name string O($$, OP_GET_CLASS); }; @@ -505,8 +519,8 @@ expr: | expr '&' expr { $$=$1; P($$, $3); O($$, OP_BIN_AND) } | expr '|' expr { $$=$1; P($$, $3); O($$, OP_BIN_OR) } | expr '#' expr { $$=$1; P($$, $3); O($$, OP_BIN_XOR) } -| expr "&&" expr { $$=$1; P($$, $3); O($$, OP_LOG_AND) } -| expr "||" expr { $$=$1; P($$, $3); O($$, OP_LOG_OR) } +| expr "&&" expr { $$=$1; PNC($$, $3); O($$, OP_LOG_AND) } +| expr "||" expr { $$=$1; PNC($$, $3); O($$, OP_LOG_OR) } | expr "##" expr { $$=$1; P($$, $3); O($$, OP_LOG_XOR) } | expr '<' expr { $$=$1; P($$, $3); O($$, OP_NUM_LT) } | expr '>' expr { $$=$1; P($$, $3); O($$, OP_NUM_GT) } @@ -560,7 +574,7 @@ empty: /* empty */ { $$=N(POOL) }; */ static int yylex(YYSTYPE *lvalp, void *pc) { - #define lexical_brackets_nestage PC.brackets_nestages[PC.sp] + #define lexical_brackets_nestage PC.brackets_nestages[PC.ls_sp] #define RC {result=c; goto break2; } register int c; @@ -587,10 +601,16 @@ static int yylex(YYSTYPE *lvalp, void *p PC.col++; if(c=='@' && PC.col==0+1) { + if(PC.ls==LS_DEF_SPECIAL_BODY) { + // @SPECIAL + // ... + // @