From: Jay Freeman (saurik) Date: Wed, 16 Dec 2015 14:39:31 +0000 (-0800) Subject: Move lexer hacks for ++ and -- to LexCrement rule. X-Git-Tag: v0.9.590~197 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/9ea4298b4c70c7a5994bdd6726dd188cda01b880 Move lexer hacks for ++ and -- to LexCrement rule. --- diff --git a/Parser.ypp.in b/Parser.ypp.in index 7d12aa2..27bcb3c 100644 --- a/Parser.ypp.in +++ b/Parser.ypp.in @@ -147,21 +147,11 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY token = tk::_yield__; break; - case tk::HyphenHyphen: - if (driver.newline_ == CYDriver::NewLineLast) - token = tk::HyphenHyphen_; - break; - case tk::NewLine: driver.newline_ = CYDriver::NewLineHere; if (!driver.next_) goto lex; break; - - case tk::PlusPlus: - if (driver.newline_ == CYDriver::NewLineLast) - token = tk::PlusPlus_; - break; } driver.next_ = false; @@ -1115,15 +1105,19 @@ AccessExpression ; LeftHandSideExpression - : AccessExpression { $$ = $1; } + : AccessExpression LexCrement { $$ = $1; } | LexSetRegExp IndirectExpression { $$ = $2; } ; /* }}} */ /* 12.4 Postfix Expressions {{{ */ +LexCrement + : { CYLIN(PlusPlus); CYLIN(HyphenHyphen); } + ; + PostfixExpression - : AccessExpression { $$ = $1; } - | AccessExpression "++" { $$ = CYNew CYPostIncrement($1); } - | AccessExpression "--" { $$ = CYNew CYPostDecrement($1); } + : AccessExpression LexCrement { $$ = $1; } + | AccessExpression LexCrement "++" { $$ = CYNew CYPostIncrement($1); } + | AccessExpression LexCrement "--" { $$ = CYNew CYPostDecrement($1); } ; /* }}} */ /* 12.5 Unary Operators {{{ */ @@ -1487,7 +1481,7 @@ ForStatementInitializer ; ForInStatementInitializer - : AccessExpression { $$ = $1; } + : AccessExpression LexCrement { $$ = $1; } | LexSetRegExp IndirectExpression { $$ = $2; } | LexSetRegExp Var_ ForBinding { $$ = CYNew CYForVariable($3); } | LexSetRegExp ForDeclaration { $$ = $2; }