--- parser3/src/main/compile.y 2002/09/20 09:26:32 1.196 +++ parser3/src/main/compile.y 2002/10/17 10:57:06 1.202 @@ -5,7 +5,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.y,v 1.196 2002/09/20 09:26:32 paf Exp $ + $Id: compile.y,v 1.202 2002/10/17 10:57:06 paf Exp $ */ /** @@ -34,8 +34,8 @@ #include "pa_vdouble.h" #include "pa_globals.h" #include "pa_vvoid.h" +#include "pa_vmethod_frame.h" -#define SELF_ELEMENT_NAME "self" #define USE_CONTROL_METHOD_NAME "USE" static int real_yyerror(parse_control *pc, char *s); @@ -95,20 +95,21 @@ static int yylex(YYSTYPE *lvalp, void *p %left '<' '>' "<=" ">=" "lt" "gt" "le" "ge" %left "==" "!=" "eq" "ne" %left "is" "def" "in" "-f" "-d" -%left '!' /* bitwise */ %left "!|" %left '|' %left '&' -%left '~' -%left ">>" -%left "<<" +%left "<<" ">>" /* numerical */ -%left '-' '+' -%left '*' '/' '%' '\\' -%left NEG /* negation: unary - */ +%left '+' '-' +%left '*' '/' '\\' '%' +%left NUNARY /* unary - + */ + +/* out-of-group */ +%left '~' /* bitwise */ +%left '!' /* logical */ %% all: @@ -159,7 +160,7 @@ control_method: '@' STRING '\n' } } else if(command==USE_CONTROL_METHOD_NAME) { for(int i=0; isize(); i+=2) - PC.request->use_file(*LA2S(strings_code, i)); + PC.request->use_file(PC.request->main_class, *LA2S(strings_code, i)); } else if(command==BASE_NAME) { if(PC.cclass->base_class()) { // already changed from default? strcpy(PC.error, "class already have a base '"); @@ -273,14 +274,10 @@ name_without_curly_rdive_read: name_with } else { O($$, OP_WITH_READ); /* stack: starting context */ - // OP_VALUE+string+OP_GET_ELEMENT. -> OP_VALUE+string+...OR_OPERATOR/OR_JUNCTION_EXP. - if(diving_code->size()==3) // ELEMENT without .SUBELEMENT - diving_code->put_int(2, - PC.in_call_value? - OP_GET_ELEMENT_OR_OPERATOR// possibly ^if [search for operator] - :OP_GET_ELEMENT_OR_JUNCTION_EXPAND // possibly $junction [if junction, expand it] - ); - + // ^if ELEMENT -> ^if ELEMENT_OR_OPERATOR + // OP_VALUE+string+OP_GET_ELEMENT. -> OP_VALUE+string+OP_GET_ELEMENT_OR_OPERATOR. + if(PC.in_call_value && diving_code->size()==3) + diving_code->put_int(2, OP_GET_ELEMENT_OR_OPERATOR); P($$, diving_code); } /* diving code; stack: current context */ @@ -533,8 +530,8 @@ expr: | '\'' string_inside_quotes_value '\'' { $$ = $2; } | '(' expr ')' { $$ = $2; } /* stack: operand // stack: @operand */ -| '-' expr %prec NEG { $$=$2; O($$, OP_NEG) } -| '+' expr %prec NEG { $$=$2 } +| '-' expr %prec NUNARY { $$=$2; O($$, OP_NEG) } +| '+' expr %prec NUNARY { $$=$2 } | '~' expr { $$=$2; O($$, OP_INV) } | '!' expr { $$=$2; O($$, OP_NOT) } | "def" expr { $$=$2; O($$, OP_DEF) }