--- parser3/src/main/compile.y 2001/04/06 10:20:36 1.124 +++ parser3/src/main/compile.y 2001/04/28 08:43:56 1.129 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.y,v 1.124 2001/04/06 10:20:36 paf Exp $ + $Id: compile.y,v 1.129 2001/04/28 08:43:56 paf Exp $ */ /** @@ -29,9 +29,6 @@ #define YYPRINT(file, type, value) yyprint(file, type, value) #include "pa_config_includes.h" -#include -#include -#include #include "compile_tools.h" #include "pa_value.h" @@ -44,9 +41,9 @@ #define SELF_ELEMENT_NAME "self" #define USE_CONTROL_METHOD_NAME "USE" -int real_yyerror(parse_control *pc, char *s); +static int real_yyerror(parse_control *pc, char *s); static void yyprint(FILE *file, int type, YYSTYPE value); -int yylex(YYSTYPE *lvalp, void *pc); +static int yylex(YYSTYPE *lvalp, void *pc); // local convinient inplace typecast & var @@ -85,6 +82,7 @@ int yylex(YYSTYPE *lvalp, void *pc); %token DEF "def" %token IN "in" %token FEXISTS "-f" +%token DEXISTS "-d" %token IS "is" /* logical */ @@ -95,7 +93,7 @@ int yylex(YYSTYPE *lvalp, void *pc); %left "==" "!=" %left "||" %left "&&" -%left "def" "in" "-f" +%left "def" "in" "-f" "-d" %left '!' /* bitwise */ @@ -137,7 +135,7 @@ control_method: '@' STRING '\n' YYERROR; } if(command==CLASS_NAME) { - if(PC.cclass) { // already changed from default? + if(PC.cclass!=&PC.request->OP) { // already changed from default? strcpy(PC.error, "class already have a name '"); strncat(PC.error, PC.cclass->name().cstr(), 100); strcat(PC.error, "'"); @@ -488,6 +486,7 @@ expr: | "def" expr { $$=$2; O($$, OP_DEF) } | "in" expr { $$=$2; O($$, OP_IN) } | "-f" expr { $$=$2; O($$, OP_FEXISTS) } +| "-d" expr { $$=$2; O($$, OP_DEXISTS) } /* stack: a,b // stack: a@b */ | expr '-' expr { $$=$1; P($$, $3); O($$, OP_SUB) } | expr '+' expr { $$=$1; P($$, $3); O($$, OP_ADD) } @@ -579,8 +578,9 @@ static int yylex(YYSTYPE *lvalp, void *p if(c=='^' && PC.ls!=LS_COMMENT && PC.ls!=LS_DEF_COMMENT) switch(*PC.source) { - // escaping: ^^ ^$ ^; ^) ^} ^( ^{ ^" + // escaping: ^^ & co case '^': case '$': case ';': + case '(': case ')': case '[': case ']': case '{': case '}': case '"': @@ -758,11 +758,19 @@ static int yylex(YYSTYPE *lvalp, void *p lexical_brackets_nestage++; RC; case '-': - if(*PC.source=='f') { // -f + switch(*PC.source) { + case 'f': // -f skip_analized=1; result=FEXISTS; - } else + goto break2; + case 'd': // -d + skip_analized=1; + result=DEXISTS; + goto break2; + default: result=c; + goto break2; + } goto break2; case '+': case '*': case '/': case '%': case '~': @@ -864,13 +872,14 @@ static int yylex(YYSTYPE *lvalp, void *p case 0: case ' ': case '\t': case '\n': case ';': - case ']': case '}': case ')': case '"': + case ']': case '}': case ')': + case '"': case '\'': case '<': case '>': // these stand for HTML brackets and expression binary ops case '+': case '*': case '/': case '%': case '&': case '|': case '=': case '!': // common delimiters - case '\'': case ',': + case ',': pop_LS(PC); PC.source--; if(--PC.col<0) { PC.line--; PC.col=-1; } result=EON;