--- parser3/src/main/compile.y 2001/02/22 10:43:45 1.16 +++ 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; @@ -128,12 +128,9 @@ constructor_value: ; constructor_one_param_value: empty /* optimized $var() case */ -| string_value /* optimized $var(STRING) case */ +| STRING /* optimized $var(STRING) case */ | complex_constructor_param_value /* $var(something complex) */ ; -string_value: STRING { - $$=LAS2LAVS($1); -}; complex_constructor_param_value: complex_constructor_param_body { $$=N(pool); OP($$, OP_CREATE_EWPOOL); /* stack: empty write context */ @@ -237,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); }; @@ -263,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 */ @@ -283,7 +283,7 @@ codes__excluding_sole_str_literal: ; write_str_literal: STRING { $$=$1; - OP($$, OP_WRITE_STRING); + OP($$, OP_WRITE); }; /* */ @@ -440,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; @@ -458,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; @@ -612,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!