--- parser3/src/main/compile.y 2001/02/21 15:00:02 1.10 +++ parser3/src/main/compile.y 2001/02/22 10:43:45 1.16 @@ -13,6 +13,7 @@ #include "compile_tools.h" #include "pa_value.h" +#include "pa_request.h" int real_yyerror(parse_control *pc, char *s); static void yyprint(FILE *file, int type, YYSTYPE value); @@ -26,7 +27,7 @@ int yylex(YYSTYPE *lvalp, void *pc); %pure_parser -%token END_OF_NAME +%token EON %token STRING %token BOGUS @@ -35,7 +36,7 @@ int yylex(YYSTYPE *lvalp, void *pc); all: one_big_piece { String& name_main=*new(pool) String(pool); - name_main.APPEND_CONST("main"); + name_main.APPEND_CONST(MAIN_METHOD_NAME); Array& param_names=*new(pool) Array(pool); Array& local_names=*new(pool) Array(pool); Method *method=new(pool) Method(pool, name_main, param_names, local_names, *$1); @@ -86,10 +87,10 @@ action: get | put | with | call; get: '$' any_name { $$=$2; /* stack: resulting value */ - OP($$, OP_WRITE); /* value=pop; write(value) */ + OP($$, OP_WRITE_VALUE); /* value=pop; write(value) */ }; -any_name: name_without_curly_rdive END_OF_NAME | name_in_curly_rdive; +any_name: name_without_curly_rdive EON | name_in_curly_rdive; name_in_curly_rdive: '{' name_without_curly_rdive '}' { $$=$2 }; name_without_curly_rdive: name_rdive { @@ -126,11 +127,13 @@ constructor_value: | constructor_two_params_value /* $var(=;2*2) $var(%d;2*2) $var(+;1) */ ; constructor_one_param_value: - empty_value /* optimized $var() case */ -| STRING /* optimized $var(STRING) case */ + empty /* optimized $var() case */ +| string_value /* optimized $var(STRING) case */ | complex_constructor_param_value /* $var(something complex) */ ; -empty_value: empty; +string_value: STRING { + $$=LAS2LAVS($1); +}; complex_constructor_param_value: complex_constructor_param_body { $$=N(pool); OP($$, OP_CREATE_EWPOOL); /* stack: empty write context */ @@ -163,7 +166,7 @@ constructor_two_params_value: STRING ';' /* call */ -call: '^' name_expr_dive store_params END_OF_NAME { /* ^field.$method{vasya} */ +call: '^' name_expr_dive store_params EON { /* ^field.$method{vasya} */ /* TODO: подсмотреть в $3, и если там в первом элементе первая буква ":" то выкинуть её и делать не OP_WITH_READ, а WITH_ROOT @@ -234,7 +237,7 @@ name_expr_with_subvar_value: STRING subv $$=N(pool); OP($$, OP_CREATE_EWPOOL); P($$, $1); - OP($$, OP_WRITE); + OP($$, OP_WRITE_STRING); P($$, $2); OP($$, OP_REDUCE_EWPOOL); }; @@ -249,7 +252,7 @@ subvar_ref_name_rdive: STRING { 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); + OP($$, OP_GET_ELEMENT__WRITE_VALUE); }; @@ -260,7 +263,7 @@ with: '$' name_without_curly_rdive '{' c OP($$, OP_CREATE_RWPOOL); P($$, $4); OP($$, OP_REDUCE_RWPOOL); - OP($$, OP_WRITE); + OP($$, OP_WRITE_VALUE); }; /* codes_in_brackets */ @@ -280,7 +283,7 @@ codes__excluding_sole_str_literal: ; write_str_literal: STRING { $$=$1; - OP($$, OP_WRITE); + OP($$, OP_WRITE_STRING); }; /* */ @@ -429,10 +432,10 @@ int yylex(YYSTYPE *lvalp, void *pc) { c==')' || c=='}') { pop_LS(PC); PC->source--; PC->col--; - result=END_OF_NAME; + result=EON; goto break2; } - if(begin==end && c=='{') { /* ${name}, no need of END_OF_NAME, switching LS */ + if(begin==end && c=='{') { /* ${name}, no need of EON, switching LS */ PC->ls=LS_VAR_NAME_CURLY; result=c; goto break2; @@ -589,7 +592,7 @@ int yylex(YYSTYPE *lvalp, void *pc) { } pop_LS(PC); PC->source--; PC->col--; - result=END_OF_NAME; + result=EON; goto break2; } if(c==0) { @@ -620,7 +623,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;