--- parser3/src/main/compile.y 2001/03/07 09:29:54 1.61 +++ parser3/src/main/compile.y 2001/03/07 10:10:50 1.63 @@ -1,5 +1,5 @@ /* - $Id: compile.y,v 1.61 2001/03/07 09:29:54 paf Exp $ + $Id: compile.y,v 1.63 2001/03/07 10:10:50 paf Exp $ */ %{ @@ -385,10 +385,16 @@ with: '$' name_without_curly_rdive '{' c any_expr: empty_double_value /* optimized $var() case */ -| expr /* $var(something) */ +| optimized_expr /* $var(something) */ ; +optimized_expr: expr { + if(($$=$1)->size()==2) { // only one string literal in there? + change_string_literal_to_double_literal($$); // make that string literal Double + } +}; expr: - number + STRING +| '"' STRING '"' { $$ = $2; } | '(' expr ')' { $$ = $2; } /* stack: operand // stack: @operand */ | '-' expr %prec NEG { $$=$2; O($$, OP_NEG) } @@ -435,19 +441,6 @@ complex_expr_value: complex_expr { write_str_literal: STRING { $$=$1; O($$, OP_WRITE); - /* - - if(SLA2S($1)->size()) { - $$=$1; - O($$, OP_WRITE); - } else { - // optimized case of special end of macro. see yylex - $$=N(POOL); - } - */ -}; -number: STRING { - change_string_literal_to_double_literal($$=$1); }; empty_double_value: /* empty */ { $$=VL(NEW VDouble(POOL)) }; @@ -509,7 +502,7 @@ int yylex(YYSTYPE *lvalp, void *pc) { // append piece till ^ PC->string->APPEND(begin, end-begin, PC->file, begin_line); } - // reset piece 'start' position & line + // reset piece 'begin' position & line begin=PC->source; // ^ begin_line=PC->line; // skip over ^ and _ @@ -656,22 +649,27 @@ int yylex(YYSTYPE *lvalp, void *pc) { switch(*PC->source) { // case '?': // ok [and bad cases, yacc would bark at them] case 't': // lt gt [et nt] - result=c=='l'?SLT:c=='g'?SGT:BAD_STRING_COMPARISON_OPERATOR; + result=c=='l'?SLT:c=='g'?SGT:BAD_STRING_COMPARISON_OPERATOR; + skip_analized_char=true; goto break2; case 'e': // le ge ne [ee] result=c=='l'?SLE:c=='g'?SGE:c=='n'?SNE:BAD_STRING_COMPARISON_OPERATOR; + skip_analized_char=true; goto break2; case 'q': // eq [lq gq nq] result=c=='e'?SEQ:BAD_STRING_COMPARISON_OPERATOR; + skip_analized_char=true; goto break2; } break; case ' ': case '\t': case '\n': - if(end!=begin) { - // append piece till whitespace char - PC->string->APPEND(begin, end-begin, PC->file, begin_line); + if(end!=begin) { // there were a string after previous operator? + result=0; // return that string + goto break2; } - // reset piece 'start' position & line + // that's a leading|traling space or after-operator-space + // ignoring it + // reset piece 'begin' position & line begin=PC->source; // after whitespace char begin_line=PC->line; continue;