--- parser3/src/main/compile.y 2001/02/22 08:16:31 1.14 +++ parser3/src/main/compile.y 2001/02/22 14:14:07 1.18 @@ -87,7 +87,7 @@ action: get | put | with | call; get: '$' any_name { $$=$2; /* stack: resulting value */ - OP($$, OP_WRITE_VALUE); /* value=pop; write(value) */ + OP($$, OP_WRITE); /* value=pop; write(value) */ }; any_name: name_without_curly_rdive EON | name_in_curly_rdive; @@ -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 */ @@ -235,22 +234,25 @@ name_expr_with_subvar_value: STRING subv $$=N(pool); OP($$, OP_CREATE_EWPOOL); P($$, $1); - OP($$, OP_WRITE_STRING); + OP($$, OP_WRITE); 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; - OP($$, OP_GET_ELEMENT__WRITE_VALUE); + OP($$, OP_GET_ELEMENT__WRITE); }; @@ -261,7 +263,7 @@ with: '$' name_without_curly_rdive '{' c OP($$, OP_CREATE_RWPOOL); P($$, $4); OP($$, OP_REDUCE_RWPOOL); - OP($$, OP_WRITE_VALUE); + OP($$, OP_WRITE); }; /* codes_in_brackets */ @@ -281,7 +283,7 @@ codes__excluding_sole_str_literal: ; write_str_literal: STRING { $$=$1; - OP($$, OP_WRITE_STRING); + OP($$, OP_WRITE); }; /* */ @@ -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;