--- parser3/src/main/compile.y 2002/10/15 14:00:44 1.200 +++ parser3/src/main/compile.y 2002/10/22 09:27:10 1.203 @@ -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.200 2002/10/15 14:00:44 paf Exp $ + $Id: compile.y,v 1.203 2002/10/22 09:27:10 paf Exp $ */ /** @@ -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: @@ -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) } @@ -647,7 +644,14 @@ static int yylex(YYSTYPE *lvalp, void *p } else // @ in first column inside some code [when could that be?] result=BAD_METHOD_DECL_START; goto break2; - } else if(c=='^') + } else if(c=='^') { + if(PC.ls==LS_METHOD_AFTER) { + // handle after-method situation + pop_LS(PC); + result=EON; + skip_analized=-1; // return to punctuation afterwards to assure it's literality + goto break2; + } switch(PC.ls) { case LS_EXPRESSION_VAR_NAME_WITH_COLON: case LS_EXPRESSION_VAR_NAME_WITHOUT_COLON: @@ -672,19 +676,12 @@ default: PC.string->APPEND_CLEAN(begin, end-begin, PC.file, begin_line); } // reset piece 'begin' position & line - end=begin=PC.source; // ^ + begin=PC.source; // ->punctuation begin_line=PC.line; - if(PC.ls==LS_METHOD_AFTER) { - pop_LS(PC); - result=EON; - skip_analized=-1; // return to ^ afterwards to assure it's literality - goto break2; - } else { - // skip over _ after ^ - PC.source++; PC.col++; - // skip analysis = forced literal - continue; - } + // skip over _ after ^ + PC.source++; PC.col++; + // skip analysis = forced literal + continue; // converting ^#HH into char(hex(HH)) case '#': @@ -708,13 +705,15 @@ default: PC.source+=3; PC.col+=3; // reset piece 'begin' position & line - begin=PC.source; // ^ + begin=PC.source; // ->after ^#HH begin_line=PC.line; + // skip analysis = forced literal continue; } break; } break; + } } // #comment start skipping if(c=='#' && PC.col==1) {