--- parser3/src/main/compile.y 2001/08/10 12:53:32 1.161 +++ parser3/src/main/compile.y 2001/08/22 07:31:54 1.164 @@ -6,7 +6,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) */ %{ -static char *RCSId="$Id: compile.y,v 1.161 2001/08/10 12:53:32 parser Exp $"; +static char *RCSId="$Id: compile.y,v 1.164 2001/08/22 07:31:54 parser Exp $"; /** @todo parser4: @@ -241,7 +241,7 @@ get: get_value { $$=$1; /* stack: resulting value */ O($$, OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */ }; -get_value: '$' get_name_value { $$=$2 } +get_value: '$' get_name_value { $$=$2 }; get_name_value: name_without_curly_rdive EON | name_in_curly_rdive; name_in_curly_rdive: '{' name_without_curly_rdive '}' { $$=$2 }; name_without_curly_rdive: @@ -298,9 +298,9 @@ name_expr_wdive_write: '.' name_expr_div name_expr_wdive_class: class_prefix name_expr_dive_code { $$=$1; P($$, $2) }; construct: - construct_square | - construct_round | - construct_curly + construct_square +| construct_round +| construct_curly ; construct_square: '[' any_constructor_code_value ']' { // stack: context, name @@ -311,7 +311,7 @@ construct_square: '[' any_constructor_co construct_round: '(' expr_value ')' { // stack: context, name $$=$2; // stack: context, name, value - O($$, OP_CONSTRUCT_EXPR); /* value=pop; name=pop; context=pop; construct(context,name,value) */ + O($$, OP_CONSTRUCT_EXPR); /* value=pop->as_expr_result; name=pop; context=pop; construct(context,name,value) */ } ; construct_curly: '{' maybe_codes '}' { @@ -437,7 +437,7 @@ name_expr_with_subvar_value: STRING subv P($$, $2); O($$, OP_REDUCE_EWPOOL); }; -name_curly_code_value: '(' codes ')' { +name_curly_code_value: '[' codes ']' { $$=N(POOL); O($$, OP_CREATE_EWPOOL); P($$, $2); @@ -595,12 +595,18 @@ static int yylex(YYSTYPE *lvalp, void *p PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); } // reset piece 'begin' position & line - begin=PC.source; // ^ + end=begin=PC.source; // ^ begin_line=PC.line; - // skip over ^ and _ - PC.source++; PC.col++; - // skip analysis = forced literal - continue; + if(PC.ls==LS_METHOD_AFTER) { + pop_LS(PC); + result=EON; + goto break2; + } else { + // skip over _ after ^ + PC.source++; PC.col++; + // skip analysis = forced literal + continue; + } // converting ^#HH into char(hex(HH)) case '#': @@ -665,13 +671,13 @@ static int yylex(YYSTYPE *lvalp, void *p RC; } break; - case ')': // $name.(code<)> + case ']': // $name.(code<)> if(--lexical_brackets_nestage==0) { pop_LS(PC); RC; } break; - case '(': + case '[': lexical_brackets_nestage++; break; } @@ -937,6 +943,16 @@ static int yylex(YYSTYPE *lvalp, void *p result=EON; goto break2; case '[': + // $name.<[>code] + if(PC.col>1/*not first column*/ && ( + end[-1]=='$'/*was start of get*/ || + end[-1]==':'/*was class name delim */ || + end[-1]=='.'/*was name delim */ + )) { + push_LS(PC, LS_USER); + lexical_brackets_nestage=1; + RC; + } PC.ls=LS_VAR_SQUARE; lexical_brackets_nestage=1; RC; @@ -950,15 +966,6 @@ static int yylex(YYSTYPE *lvalp, void *p RC; case '(': - // $name.<(>code) - if(PC.col>1/*not first column*/ && ( - end[-1]=='.'/*was dot */ || - end[-1]=='$'/*was start of get*/ - )) { - push_LS(PC, LS_USER); - lexical_brackets_nestage=1; - RC; - } PC.ls=LS_VAR_ROUND; lexical_brackets_nestage=1; RC; @@ -972,8 +979,8 @@ static int yylex(YYSTYPE *lvalp, void *p case LS_VAR_NAME_CURLY: switch(c) { - case '(': - // ${name.<(>code)} + case '[': + // ${name.<[>code)} push_LS(PC, LS_USER); lexical_brackets_nestage=1; RC; @@ -1033,6 +1040,16 @@ static int yylex(YYSTYPE *lvalp, void *p case LS_METHOD_NAME: switch(c) { case '[': + // $name.<[>code) + if(PC.col>1/*not first column*/ && ( + end[-1]=='^'/*was start of call*/ || // never, ^[ is literal... + end[-1]==':'/*was class name delim */ || + end[-1]=='.'/*was name delim */ + )) { + push_LS(PC, LS_USER); + lexical_brackets_nestage=1; + RC; + } PC.ls=LS_METHOD_SQUARE; lexical_brackets_nestage=1; RC; @@ -1041,15 +1058,6 @@ static int yylex(YYSTYPE *lvalp, void *p lexical_brackets_nestage=1; RC; case '(': - // $name.<(>code) - if(PC.col>1/*not first column*/ && ( - end[-1]=='.'/*was dot */ || - end[-1]=='^'/*was start of call*/ - )) { - push_LS(PC, LS_USER); - lexical_brackets_nestage=1; - RC; - } PC.ls=LS_METHOD_ROUND; lexical_brackets_nestage=1; RC;