--- parser3/src/main/compile.y 2001/03/06 13:07:03 1.51 +++ parser3/src/main/compile.y 2001/03/06 14:09:36 1.53 @@ -1,5 +1,5 @@ /* - $Id: compile.y,v 1.51 2001/03/06 13:07:03 paf Exp $ + $Id: compile.y,v 1.53 2001/03/06 14:09:36 paf Exp $ */ %{ @@ -19,6 +19,7 @@ #include "pa_value.h" #include "pa_request.h" #include "pa_vobject.h" +#include "pa_vdouble.h" #define SELF_NAME "self" #define USES_NAME "USES" @@ -184,9 +185,9 @@ name_without_curly_rdive_code: name_adva /* put */ -put: '$' name_expr_wdive '[' constructor_value ']' { +put: '$' name_expr_wdive constructor_value { $$=$2; /* stack: context,name */ - P($$, $4); /* stack: context,name,constructor_value */ + P($$, $3); /* stack: context,name,constructor_value */ OP($$, OP_CONSTRUCT); /* value=pop; name=pop; context=pop; construct(context,name,value) */ }; name_expr_wdive: @@ -216,17 +217,21 @@ name_expr_wdive_root: ':' name_expr_dive name_expr_wdive_class: class_prefix name_expr_dive_code { $$=$1; P($$, $2) }; constructor_value: - empty_value /* optimized $var() case */ -| STRING /* optimized $var(STRING) case */ -| complex_constructor_param_value /* $var(something complex) */ + '[' constructor_code_value ']' { $$=$2 } +| '(' expression_value ')' { $$=$2 } ; -complex_constructor_param_value: complex_constructor_param_body { +constructor_code_value: + empty_value /* optimized $var[] case */ +| STRING /* optimized $var[STRING] case */ +| complex_constructor_code_value /* $var[something complex] */ +; +complex_constructor_code_value: complex_constructor_code { $$=N(POOL); OP($$, OP_CREATE_EWPOOL); /* stack: empty write context */ P($$, $1); /* some codes to that context */ OP($$, OP_REDUCE_EWPOOL); /* context=pop; stack: context.value() */ }; -complex_constructor_param_body: codes__excluding_sole_str_literal; +complex_constructor_code: codes__excluding_sole_str_literal; codes__excluding_sole_str_literal: action | code codes { $$=$1; P($$, $2) }; /* call */ @@ -258,7 +263,7 @@ store_param_part: $$=$1; OP($$, OP_STORE_PARAM); } -| complex_constructor_param_value { /* (something complex) */ +| complex_constructor_code_value { /* (something complex) */ $$=$1; OP($$, OP_STORE_PARAM); } @@ -340,6 +345,29 @@ with: '$' name_without_curly_rdive '{' c OP($$, OP_WRITE); }; +/* expression */ + +expression_value: + empty_value /* optimized $var() case */ +| STRING /* optimized $var(STRING) case */ +| complex_expression /* $var(something complex) */ +; +complex_expression: expression_operand '*' expression_operand { + $$=$1; // stack: first operand + P($$, $3); // stack: first,second operands + OP($$, OP_MUL); // value=first*second; stack: value +}; +expression_operand: STRING; + +/* +complex_expression_value: complex_expression { + $$=N(POOL); + OP($$, OP_CREATE_SWPOOL); /* stack: empty write context * / + P($$, $1); /* some codes to that context * / + OP($$, OP_REDUCE_SWPOOL); /* context=pop; stack: context.get_string() * / +}; +*/ + /* basics */ write_str_literal: STRING {