--- parser3/src/main/compile.y 2001/07/24 12:26:22 1.147 +++ parser3/src/main/compile.y 2001/07/25 10:33:05 1.151 @@ -6,7 +6,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) */ %{ -static char *RCSId="$Id: compile.y,v 1.147 2001/07/24 12:26:22 parser Exp $"; +static char *RCSId="$Id: compile.y,v 1.151 2001/07/25 10:33:05 parser Exp $"; /** @todo parser4: @@ -234,7 +234,7 @@ maybe_codes: empty | codes; codes: code | codes code { $$=$1; P($$, $2) }; code: write_string | action; -action: get | put | with | call; +action: get | put | call; /* get */ @@ -304,19 +304,31 @@ name_expr_wdive_root: ':' name_expr_dive }; name_expr_wdive_class: class_prefix name_expr_dive_code { $$=$1; P($$, $2) }; -construct: construct_by_code | construct_by_expr; -construct_by_code: '[' any_constructor_code_value ']' { - $$=$2; /* stack: context, name, value */ +construct: + construct_square | + construct_round | + construct_curly +; +construct_square: '[' any_constructor_code_value ']' { + // stack: context, name + $$=$2; // stack: context, name, value O($$, OP_CONSTRUCT_VALUE); /* value=pop; name=pop; context=pop; construct(context,name,value) */ } ; -construct_by_expr: '(' expr_value ')' { - $$=$2; /* stack: context, name, value */ +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) */ } ; +construct_curly: '{' maybe_codes '}' { + // stack: context, name + $$=N(POOL); + CCA($$, $2); /* code=pop; name=pop; context=pop; construct(context,name,junction(code)) */ +}; + any_constructor_code_value: - unknown_value /* optimized $var[] case */ + empty_string_value /* optimized $var[] case */ | STRING /* optimized $var[STRING] case */ | constructor_code_value /* $var[something complex] */ ; @@ -385,7 +397,7 @@ store_curly_param_part: maybe_codes { PCA($$, $1); }; code_param_value: - unknown_value /* optimized [;...] case */ + empty_void_value /* optimized [;...] case */ | STRING /* optimized [STRING] case */ | constructor_code_value /* [something complex] */ ; @@ -452,16 +464,6 @@ class_prefix: STRING ':' { }; -/* with */ - -with: '$' name_without_curly_rdive '{' maybe_codes '}' { - $$=$2; - O($$, OP_CREATE_RWPOOL); - P($$, $4); - O($$, OP_REDUCE_RWPOOL); - O($$, OP_WRITE_VALUE); -}; - /* expr */ expr_value: expr { @@ -524,7 +526,8 @@ write_string: STRING { change_string_literal_to_write_string_literal($$=$1) }; -unknown_value: /* empty */ { $$=VL(NEW VVoid(POOL)) }; +empty_void_value: /* empty */ { $$=VL(NEW VVoid(POOL)) }; +empty_string_value: /* empty */ { $$=VL(NEW VString(POOL)) }; empty: /* empty */ { $$=N(POOL) }; %% @@ -642,19 +645,6 @@ static int yylex(YYSTYPE *lvalp, void *p RC; case '@': if(PC.col==0+1) { - if( - PC.source[0]=='e' && - PC.source[1]=='n' && - PC.source[2]=='d' && - PC.source[3]=='\n') { - if(end!=begin) { - // append piece till @ - PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); - } - PC.source+=3+1; begin=PC.source; - PC.line++; begin_line=PC.line; - continue; - } push_LS(PC, LS_DEF_NAME); RC; }