--- parser3/src/main/compile.y 2001/05/21 17:12:58 1.136 +++ parser3/src/main/compile.y 2001/07/02 12:56:33 1.145 @@ -4,9 +4,9 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: compile.y,v 1.136 2001/05/21 17:12:58 parser Exp $ */ +%{ +static char *RCSId="$Id: compile.y,v 1.145 2001/07/02 12:56:33 parser Exp $"; /** @todo parser4: @@ -19,7 +19,6 @@ -#: in iis make up specialized Pool object for that */ -%{ #define YYSTYPE Array/**/ * #define YYPARSE_PARAM pc #define YYLEX_PARAM pc @@ -34,7 +33,7 @@ #include "pa_vobject.h" #include "pa_vdouble.h" #include "pa_globals.h" -#include "pa_vnothing.h" +#include "pa_vvoid.h" #define SELF_ELEMENT_NAME "self" #define USE_CONTROL_METHOD_NAME "USE" @@ -135,7 +134,7 @@ control_method: '@' STRING '\n' YYERROR; } if(command==CLASS_NAME) { - if(PC.cclass!=&PC.request->OP) { // already changed from default? + if(PC.cclass) { // already changed from default? strcpy(PC.error, "class already have a name '"); strncat(PC.error, PC.cclass->name().cstr(), 100); strcat(PC.error, "'"); @@ -344,9 +343,9 @@ call_value: '^' call_name store_params E O($$, OP_GET_METHOD_FRAME); /* stack: context,method_frame */ YYSTYPE params_code=$3; - if(params_code->size()==3) // probably [] case. [OP_VALUE + Nothing + STORE_PARAM] + if(params_code->size()==3) // probably [] case. [OP_VALUE + Void + STORE_PARAM] if(Value *value=LA2V(params_code)) // it is OP_VALUE + value? - if(!value->is_defined()) // value is VNothing? + if(!value->is_defined()) // value is VVoid? params_code=0; // ^zzz[] case. don't append lone empty param. if(params_code) P($$, params_code); // filling method_frame.store_params @@ -477,6 +476,7 @@ expr: | get_value | call_value | '"' string_inside_quotes_value '"' { $$ = $2; } +| '\'' string_inside_quotes_value '\'' { $$ = $2; } | '(' expr ')' { $$ = $2; } /* stack: operand // stack: @operand */ | '-' expr %prec NEG { $$=$2; O($$, OP_NEG) } @@ -527,7 +527,7 @@ write_string: STRING { change_string_literal_to_write_string_literal($$=$1) }; -unknown_value: /* empty */ { $$=VL(NEW VNothing(POOL)) }; +unknown_value: /* empty */ { $$=VL(NEW VVoid(POOL)) }; empty: /* empty */ { $$=N(POOL) }; %% @@ -665,11 +665,18 @@ static int yylex(YYSTYPE *lvalp, void *p break; // STRING IN EXPRESSION - case LS_EXPRESSION_STRING: + case LS_EXPRESSION_STRING_QUOTED: + case LS_EXPRESSION_STRING_APOSTROFED: switch(c) { case '"': - pop_LS(PC); //"abc". - RC; + case '\'': + if( + PC.ls == LS_EXPRESSION_STRING_QUOTED && c=='"' || + PC.ls == LS_EXPRESSION_STRING_APOSTROFED && c=='\'') { + pop_LS(PC); //"abc". | 'abc'. + RC; + } + break; case '$': push_LS(PC, LS_VAR_NAME_SIMPLE); RC; @@ -795,7 +802,10 @@ static int yylex(YYSTYPE *lvalp, void *p result=c; goto break2; case '"': - push_LS(PC, LS_EXPRESSION_STRING); + push_LS(PC, LS_EXPRESSION_STRING_QUOTED); + RC; + case '\'': + push_LS(PC, LS_EXPRESSION_STRING_APOSTROFED); RC; case 'l': case 'g': case 'e': case 'n': if(end==begin) // right after whitespace @@ -857,6 +867,7 @@ static int yylex(YYSTYPE *lvalp, void *p // VARIABLE GET/PUT/WITH case LS_VAR_NAME_SIMPLE: case LS_EXPRESSION_VAR_NAME: + case LS_VAR_NAME_NO_COLON: if(PC.ls==LS_EXPRESSION_VAR_NAME) { // name in expr ends also before binary operators switch(c) { @@ -867,18 +878,30 @@ static int yylex(YYSTYPE *lvalp, void *p goto break2; } } + if(PC.ls==LS_VAR_NAME_NO_COLON) { + // name already has ':', stop before next + switch(c) { + case ':': + pop_LS(PC); + PC.source--; if(--PC.col<0) { PC.line--; PC.col=-1; } + result=EON; + goto break2; + } + } switch(c) { case 0: case ' ': case '\t': case '\n': case ';': case ']': case '}': case ')': case '"': case '\'': - case '<': case '>': // these stand for HTML brackets and expression binary ops + case '<': case '>': // these stand for HTML brackets AND expression binary ops case '+': case '*': case '/': case '%': case '&': case '|': case '=': case '!': // common delimiters case ',': + // before call + case '^': pop_LS(PC); PC.source--; if(--PC.col<0) { PC.line--; PC.col=-1; } result=EON; @@ -903,6 +926,7 @@ static int yylex(YYSTYPE *lvalp, void *p case '.': // name part delim case '$': // name part subvar case ':': // ':name' or 'class:name' + PC.ls=LS_VAR_NAME_NO_COLON; // stop before next ':' RC; } break; @@ -1059,6 +1083,8 @@ break2: if((c=='@' || c==0) && end[-1]=='\n') { // we are before LS_DEF_NAME or EOF? // strip last \n end--; + if(end!=begin && end[-1]=='\n') // allow one empty line before LS_DEF_NAME + end--; } if(end!=begin && PC.ls!=LS_COMMENT) { // last piece still alive and not comment? // append it