--- parser3/src/main/compile.y 2001/04/03 17:15:07 1.123 +++ 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.123 2001/04/03 17:15:07 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!=&PC.request->ROOT) { // 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, "'"); @@ -149,8 +147,6 @@ control_method: '@' STRING '\n' // creating the class PC.cclass=NEW VClass(POOL); PC.cclass->set_name(*name); - // defaulting base. may change with @BASE - PC.cclass->set_base(PC.request->ROOT); // append to request's classes PC.request->classes().put(*name, PC.cclass); } else { @@ -163,7 +159,7 @@ control_method: '@' STRING '\n' PC.request->use_file( PC.request->absolute(*LA2S(strings_code, i))); } else if(command==BASE_NAME) { - if(PC.cclass->base()!=&PC.request->ROOT) { // already changed from default? + if(PC.cclass->base()) { // already changed from default? strcpy(PC.error, "class already have a base '"); strncat(PC.error, PC.cclass->base()->name().cstr(), 100); strcat(PC.error, "'"); @@ -490,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) } @@ -581,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 '"': @@ -760,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 '~': @@ -866,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;