--- parser3/src/main/compile.y 2001/03/06 12:22:58 1.49 +++ parser3/src/main/compile.y 2001/03/06 13:24:40 1.52 @@ -1,5 +1,5 @@ /* - $Id: compile.y,v 1.49 2001/03/06 12:22:58 paf Exp $ + $Id: compile.y,v 1.52 2001/03/06 13:24:40 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" @@ -40,6 +41,7 @@ int yylex(YYSTYPE *lvalp, void *pc); %token EON %token STRING %token BOGUS +%token LOGICAL_AND LOGICAL_OR %% @@ -183,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: @@ -215,19 +217,38 @@ 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 } +| '(' constructor_expression_value ')' { $$=$2 } +; +constructor_code_value: + empty_value /* optimized $var[] case */ +| STRING /* optimized $var[STRING] case */ +| complex_constructor_code_value /* $var[something complex] */ ; -complex_constructor_param_value: complex_constructor_param_body { +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) }; +constructor_expression_value: + empty_value /* optimized $var() case */ +| STRING /* optimized $var(STRING) case */ +;/*| complex_constructor_expression_value /* $var(something complex) * / +; +complex_constructor_expression_value: complex_constructor_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() * / +}; +complex_constructor_expression: +; +*/ + /* call */ call: '^' call_name store_params EON { /* ^field.$method{vasya} */ @@ -257,7 +278,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); } @@ -387,7 +408,7 @@ int yylex(YYSTYPE *lvalp, void *pc) { char *begin=PC->source; char *end; int begin_line=PC->line; - while(1) { + while(true) { c=*(end=(PC->source++)); if(c=='\n') { @@ -411,7 +432,7 @@ int yylex(YYSTYPE *lvalp, void *pc) { begin=PC->source; // ^ begin_line=PC->line; // skip over ^ and _ - PC->source++; + PC->source++; PC->col++; // skip analysis = forced literal continue; } @@ -531,16 +552,25 @@ int yylex(YYSTYPE *lvalp, void *pc) { case '"': push_LS(PC, LS_EXPRESSION_STRING); RC; + case 'l': case 'g': case 'e': case 'n': + if(end==begin) // right after whitespace + switch(char next_c=*PC->source) { +// case '?': // ok [and bad cases, yacc would bark at them] + case 't': // lt gt [et nt] + case 'e': // le ge ne [ee] + case 'q': // eq [lq gq nq] + PC->source++; PC->col++; + PC->pending_state=next_c; + return c; + } break; case ' ': case '\t': case '\n': if(end!=begin) { // append piece till whitespace PC->string->APPEND(begin, end-begin, PC->file, begin_line); } - // skip over whitespace - PC->source++; // reset piece 'start' position & line - begin=PC->source; // ^ + begin=PC->source; // after whitespace begin_line=PC->line; continue; }