--- parser3/src/main/compile.y 2001/02/21 17:50:02 1.13 +++ parser3/src/main/compile.y 2001/02/22 14:14:07 1.18 @@ -127,11 +127,10 @@ constructor_value: | constructor_two_params_value /* $var(=;2*2) $var(%d;2*2) $var(+;1) */ ; constructor_one_param_value: - empty_value /* optimized $var() case */ + empty /* optimized $var() case */ | STRING /* optimized $var(STRING) case */ | complex_constructor_param_value /* $var(something complex) */ ; -empty_value: empty; complex_constructor_param_value: complex_constructor_param_body { $$=N(pool); OP($$, OP_CREATE_EWPOOL); /* stack: empty write context */ @@ -239,14 +238,17 @@ name_expr_with_subvar_value: STRING subv P($$, $2); OP($$, OP_REDUCE_EWPOOL); }; -subvar_ref_name_rdive: STRING { -/* - TODO: подсмотреть в $1, и если там в первом элементе первая буква ":" - то выкинуть её и делать не OP_WITH_READ, а WITH_ROOT -*/ - $$=N(pool); OP($$, OP_WITH_READ); +subvar_ref_name_rdive: subvar_ref_name_rdive_read | subvar_ref_name_rdive_root; +subvar_ref_name_rdive_read: STRING { + $$=N(pool); + OP($$, OP_WITH_READ); P($$, $1); }; +subvar_ref_name_rdive_root: ':' STRING { + $$=N(pool); + OP($$, OP_WITH_ROOT); + P($$, $2); +}; subvar_get_writes: subvar__get_write | subvar_get_writes subvar__get_write { $$=$1; P($$, $2) }; subvar__get_write: '$' subvar_ref_name_rdive { $$=$2; @@ -438,6 +440,10 @@ int yylex(YYSTYPE *lvalp, void *pc) { result=c; goto break2; } + if(c==':') { + result=c; + goto break2; + } if(c=='(') { PC->ls=LS_VAR_ROUND; lexical_brackets_nestage=1; @@ -456,6 +462,10 @@ int yylex(YYSTYPE *lvalp, void *pc) { } break; case LS_VAR_NAME_CURLY: + if(c==':') { + result=c; + goto break2; + } if(c=='}') { /* ${name} finished, restoring LS */ pop_LS(PC); result=c; @@ -610,8 +620,8 @@ break2: end--; // append last piece PC->string->APPEND(begin, end-begin, PC->file, begin_line/*, start_col*/); - // create STRING value: array of OP_STRING+string - *lvalp=L(PC->string); + // create STRING value: array of OP_VALUE+vstring + *lvalp=L(new(pool) VString(PC->string)); // new pieces storage PC->string=new(pool) String(pool); // go! @@ -621,7 +631,7 @@ break2: int real_yyerror(parse_control *pc, char *s) /* Called by yyparse on error */ { - fprintf(stderr, "[%s]\n", s); + //fprintf(stderr, "[%s]\n", s); s[MAX_STRING-1]=0; strcpy(pc->error, s); return 1;