--- parser3/src/main/compile.y 2001/08/10 13:03:05 1.162 +++ parser3/src/main/compile.y 2001/09/12 09:52:53 1.165.4.1 @@ -6,7 +6,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) */ %{ -static char *RCSId="$Id: compile.y,v 1.162 2001/08/10 13:03:05 parser Exp $"; +static char *RCSId="$Id: compile.y,v 1.165.4.1 2001/09/12 09:52:53 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 '}' { @@ -423,7 +423,7 @@ name_expr_value: STRING /* subname_is_const */ | name_expr_subvar_value /* $subname_is_var_value */ | name_expr_with_subvar_value /* xxx$part_of_subname_is_var_value */ -| name_curly_code_value /* (codes) */ +| name_square_code_value /* [codes] */ ; name_expr_subvar_value: '$' subvar_ref_name_rdive { $$=$2; @@ -437,7 +437,7 @@ name_expr_with_subvar_value: STRING subv P($$, $2); O($$, OP_REDUCE_EWPOOL); }; -name_curly_code_value: '[' codes ']' { +name_square_code_value: '[' codes ']' { $$=N(POOL); O($$, OP_CREATE_EWPOOL); P($$, $2); @@ -575,6 +575,7 @@ static int yylex(YYSTYPE *lvalp, void *p int skip_analized=0; while(true) { c=*(end=(PC.source++)); +// fprintf(stderr, "\nchar: %c %02X; nestage: %d, sp=%d", c, c, lexical_brackets_nestage, PC.sp); if(c=='\n') { PC.line++; @@ -584,7 +585,7 @@ static int yylex(YYSTYPE *lvalp, void *p if(c=='^' && PC.ls!=LS_COMMENT && PC.ls!=LS_DEF_COMMENT) switch(*PC.source) { - // escaping: ^^ & co + // ^escaping some punctuators case '^': case '$': case ';': case '(': case ')': case '[': case ']': @@ -595,12 +596,19 @@ 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; + skip_analized=-1; // return to ^ afterwards to assure it's literality + goto break2; + } else { + // skip over _ after ^ + PC.source++; PC.col++; + // skip analysis = forced literal + continue; + } // converting ^#HH into char(hex(HH)) case '#': @@ -643,6 +651,7 @@ static int yylex(YYSTYPE *lvalp, void *p // USER'S = NOT OURS case LS_USER: + case LS_NAME_SQUARE_PART: // name.[here].xxx if(PC.trim_bof) switch(c) { case '\n': case ' ': case '\t': @@ -665,14 +674,16 @@ static int yylex(YYSTYPE *lvalp, void *p RC; } break; - case ']': // $name.(code<)> - if(--lexical_brackets_nestage==0) { - pop_LS(PC); - RC; - } + case ']': + if(PC.ls==LS_NAME_SQUARE_PART) + if(--lexical_brackets_nestage==0) {// $name.[co<]?>de<]?> + pop_LS(PC); // $name.[co<]>de<]!> + RC; + } break; - case '[': - lexical_brackets_nestage++; + case '[': // $name.[co<[>de] + if(PC.ls==LS_NAME_SQUARE_PART) + lexical_brackets_nestage++; break; } break; @@ -939,10 +950,11 @@ static int yylex(YYSTYPE *lvalp, void *p case '[': // $name.<[>code] if(PC.col>1/*not first column*/ && ( - end[-1]=='.'/*was dot */ || - end[-1]=='$'/*was start of get*/ + end[-1]=='$'/*was start of get*/ || + end[-1]==':'/*was class name delim */ || + end[-1]=='.'/*was name delim */ )) { - push_LS(PC, LS_USER); + push_LS(PC, LS_NAME_SQUARE_PART); lexical_brackets_nestage=1; RC; } @@ -973,8 +985,8 @@ static int yylex(YYSTYPE *lvalp, void *p case LS_VAR_NAME_CURLY: switch(c) { case '[': - // ${name.<[>code)} - push_LS(PC, LS_USER); + // ${name.<[>code]} + push_LS(PC, LS_NAME_SQUARE_PART); lexical_brackets_nestage=1; RC; case '}': // ${name} finished, restoring LS @@ -1033,12 +1045,13 @@ static int yylex(YYSTYPE *lvalp, void *p case LS_METHOD_NAME: switch(c) { case '[': - // $name.<[>code) + // ^name.<[>code].xxx if(PC.col>1/*not first column*/ && ( - end[-1]=='.'/*was dot */ || - end[-1]=='^'/*was start of call*/ + 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); + push_LS(PC, LS_NAME_SQUARE_PART); lexical_brackets_nestage=1; RC; }