]> git.saurik.com Git - cycript.git/blobdiff - Parser.ypp.in
Move lexer hacks for \n=> and \n{ into Lex* rules.
[cycript.git] / Parser.ypp.in
index 6028184ecc46b3b00df36b9e72028c36abe94719..b85edf60b6a5cf3678aced9f9663cecc4745e679 100644 (file)
@@ -74,6 +74,7 @@
 %union { CYSpan *span_; }
 %union { CYStatement *statement_; }
 %union { CYString *string_; }
+%union { CYTarget *target_; }
 %union { CYThis *this_; }
 %union { CYTrue *true_; }
 %union { CYWord *word_; }
@@ -112,6 +113,8 @@ int cylex(YYSTYPE *, CYLocation *, void *);
 
 %code {
 
+typedef cy::parser::token tk;
+
 #undef yylex
 _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) {
     if (driver.mark_ == CYMarkIgnore);
@@ -123,19 +126,71 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
         return cy::parser::token::MarkModule;
     }
 
+  lex:
+    if (driver.newline_ == CYDriver::NewLineHere)
+        driver.newline_ = CYDriver::NewLineLast;
+    else if (driver.newline_ == CYDriver::NewLineLast)
+        driver.newline_ = CYDriver::NewLineNone;
+
     YYSTYPE data;
     int token(cylex(&data, location, driver.scanner_));
     *semantic = data.semantic_;
+
+    switch (token) {
+        case tk::_in_:
+            if (driver.in_.top())
+                token = tk::_in__;
+        break;
+
+        case tk::_return_:
+            if (driver.return_.top())
+                token = tk::_return__;
+        break;
+
+        case tk::_yield_:
+            if (driver.yield_.top())
+                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;
     return token;
 }
 
+#define CYLEX() do if (yyla.empty()) { \
+    YYCDEBUG << "Mapping a token: "; \
+    yyla.type = yytranslate_(yylex(&yyla.value, &yyla.location, driver)); \
+    YY_SYMBOL_PRINT("Next token is", yyla); \
+} while (false)
+
 #define CYMAP(to, from) do { \
-    if (yyla.empty()) \
-        yyla.type = yytranslate_(yylex(&yyla.value, &yyla.location, driver)); \
+    CYLEX(); \
     if (yyla.type == yytranslate_(token::from)) \
         yyla.type = yytranslate_(token::to); \
 } while (false)
 
+#define CYLIN(from) do { \
+    CYLEX(); \
+    if (yyla.type == yytranslate_(token::from) && driver.newline_ == CYDriver::NewLineLast) \
+        yyla.type = yytranslate_(token::from ## _); \
+} while (false)
+
 #define CYERR(location, message) do { \
     error(location, message); \
     YYABORT; \
@@ -317,13 +372,14 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %token _import_ "import"
 %token _in_ "in"
 %token _in__ "!in"
+%token _Infinity_ "Infinity"
 %token _instanceof_ "instanceof"
 %token _new_ "new"
 %token _return_ "return"
 %token _return__ "!return"
 %token _super_ "super"
-%token _super__ "!super"
 %token _switch_ "switch"
+%token _target_ "target"
 %token _this_ "this"
 %token _throw_ "throw"
 %token _try_ "try"
@@ -340,6 +396,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %token _char_ "char"
 %token _constructor_ "constructor"
 %token _double_ "double"
+%token _eval_ "eval"
 %token _final_ "final"
 %token _float_ "float"
 %token _from_ "from"
@@ -404,7 +461,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %type <argument_> ArgumentList
 %type <argument_> ArgumentListOpt
 %type <argument_> Arguments
-%type <expression_> ArrayComprehension
+%type <target_> ArrayComprehension
 %type <literal_> ArrayLiteral
 %type <expression_> ArrowFunction
 %type <functionParameter_> ArrowParameters
@@ -424,18 +481,18 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %type <statement_> BreakStatement
 %type <statement_> BreakableStatement
 %type <expression_> CallExpression_
-%type <expression_> CallExpression
+%type <target_> CallExpression
 %type <clause_> CaseBlock
 %type <clause_> CaseClause
 %type <clause_> CaseClausesOpt
 %type <catch_> Catch
 %type <identifier_> CatchParameter
 %type <statement_> ClassDeclaration
-%type <expression_> ClassExpression
+%type <target_> ClassExpression
 %type <classTail_> ClassHeritage
 %type <classTail_> ClassHeritageOpt
 %type <classTail_> ClassTail
-%type <expression_> Comprehension
+%type <target_> Comprehension
 %type <comprehension_> ComprehensionFor
 %type <comprehension_> ComprehensionIf
 %type <comprehension_> ComprehensionTail
@@ -452,14 +509,15 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %type <element_> ElementList
 %type <element_> ElementListOpt
 %type <statement_> ElseStatementOpt
-%type <statement_> EmptyStatement
+%type <for_> EmptyStatement
 %type <expression_> EqualityExpression
 %type <expression_> Expression
 %type <expression_> ExpressionOpt
+%type <for_> ExpressionStatement_
 %type <statement_> ExpressionStatement
 %type <finally_> Finally
 %type <declaration_> ForBinding
-%type <declaration_> ForDeclaration
+%type <forin_> ForDeclaration
 %type <forin_> ForInStatementInitializer
 %type <for_> ForStatementInitializer
 %type <declaration_> FormalParameter
@@ -468,11 +526,11 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %type <functionParameter_> FormalParameters
 %type <statement_> FunctionBody
 %type <statement_> FunctionDeclaration
-%type <expression_> FunctionExpression
+%type <target_> FunctionExpression
 %type <statement_> FunctionStatementList
 %type <statement_> GeneratorBody
 %type <statement_> GeneratorDeclaration
-%type <expression_> GeneratorExpression
+%type <target_> GeneratorExpression
 %type <method_> GeneratorMethod
 %type <statement_> HoistableDeclaration
 %type <identifier_> Identifier
@@ -486,24 +544,26 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %type <identifier_> LabelIdentifier
 %type <statement_> LabelledItem
 %type <statement_> LabelledStatement
-%type <expression_> LeftHandSideExpression
-%type <statement_> LetStatement
+%type <assignment_> LeftHandSideAssignment
+%type <target_> LeftHandSideExpression
+%type <bool_> LetOrConst
 %type <declaration_> LexicalBinding
+%type <for_> LexicalDeclaration_
 %type <statement_> LexicalDeclaration
 %type <literal_> Literal
 %type <propertyName_> LiteralPropertyName
 %type <expression_> LogicalANDExpression
 %type <expression_> LogicalORExpression
 %type <access_> MemberAccess
-%type <expression_> MemberExpression
+%type <target_> MemberExpression
 %type <method_> MethodDefinition
 %type <module_> ModulePath
 %type <expression_> MultiplicativeExpression
-%type <expression_> NewExpression
+%type <target_> NewExpression
 %type <null_> NullLiteral
 %type <literal_> ObjectLiteral
 %type <expression_> PostfixExpression
-%type <expression_> PrimaryExpression
+%type <target_> PrimaryExpression
 %type <propertyName_> PropertyName
 %type <property_> PropertyDefinition
 %type <property_> PropertyDefinitionList_
@@ -529,10 +589,10 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %type <statement_> StatementListOpt
 %type <statement_> StatementListItem
 %type <functionParameter_> StrictFormalParameters
-%type <expression_> SuperCall
-%type <expression_> SuperProperty
+%type <target_> SuperCall
+%type <target_> SuperProperty
 %type <statement_> SwitchStatement
-%type <expression_> TemplateLiteral
+%type <target_> TemplateLiteral
 %type <span_> TemplateSpans
 %type <statement_> ThrowStatement
 %type <statement_> TryStatement
@@ -541,6 +601,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %type <declaration_> VariableDeclaration
 %type <declarations_> VariableDeclarationList_
 %type <declarations_> VariableDeclarationList
+%type <for_> VariableStatement_
 %type <statement_> VariableStatement
 %type <statement_> WithStatement
 %type <word_> Word
@@ -565,9 +626,11 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 @end
 
 @begin ObjectiveC
+%type <expression_> AssignmentExpressionClassic
 %type <expression_> BoxableExpression
 %type <statement_> CategoryStatement
 %type <expression_> ClassSuperOpt
+%type <expression_> ConditionalExpressionClassic
 %type <implementationField_> ImplementationFieldListOpt
 %type <implementationField_> ImplementationFields
 %type <message_> ClassMessageDeclaration
@@ -576,7 +639,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %type <protocol_> ClassProtocols
 %type <protocol_> ClassProtocolsOpt
 %type <statement_> ImplementationStatement
-%type <expression_> MessageExpression
+%type <target_> MessageExpression
 %type <messageParameter_> MessageParameter
 %type <messageParameter_> MessageParameters
 %type <messageParameter_> MessageParameterList
@@ -650,7 +713,7 @@ LexPushYieldOff: { driver.yield_.push(false); };
 LexPopYield: { driver.yield_.pop(); };
 
 LexSetRegExp
-    : { driver.SetCondition(CYDriver::RegExpCondition); }
+    : { CYLEX(); if (yyla.type == yytranslate_(token::Slash)) { yyla.clear(); driver.SetRegEx(false); } else if (yyla.type == yytranslate_(token::SlashEqual)) { yyla.clear(); driver.SetRegEx(true); } }
     ;
 
 LexNewLine
@@ -730,7 +793,6 @@ Word
     | "return" { $$ = CYNew CYWord("return"); }
     | "!return" { $$ = CYNew CYWord("return"); }
     | "super" { $$ = CYNew CYWord("super"); }
-    | "!super" { $$ = CYNew CYWord("super"); }
     | "switch" { $$ = CYNew CYWord("switch"); }
     | "this" { $$ = CYNew CYWord("this"); }
     | "throw" { $$ = CYNew CYWord("throw"); }
@@ -780,7 +842,7 @@ TerminatorSoft
 
 Terminator
     : ";"
-    | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) { CYERR(@1, "required semi-colon"); } else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
+    | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && driver.newline_ == CYDriver::NewLineNone) { CYERR(@1, "required semi-colon"); } else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
     ;
 
 TerminatorOpt
@@ -819,12 +881,14 @@ IdentifierType
     | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
     | "double" { $$ = CYNew CYIdentifier("double"); }
     | "each" { $$ = CYNew CYIdentifier("each"); }
+    | "eval" { $$ = CYNew CYIdentifier("eval"); }
     | "final" { $$ = CYNew CYIdentifier("final"); }
     | "float" { $$ = CYNew CYIdentifier("float"); }
     | "from" { $$ = CYNew CYIdentifier("from"); }
     | "get" { $$ = CYNew CYIdentifier("get"); }
     | "goto" { $$ = CYNew CYIdentifier("goto"); }
     | "implements" { $$ = CYNew CYIdentifier("implements"); }
+    | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
     | "interface" { $$ = CYNew CYIdentifier("interface"); }
     | "native" { $$ = CYNew CYIdentifier("native"); }
     | "of" { $$ = CYNew CYIdentifier("of"); }
@@ -835,6 +899,7 @@ IdentifierType
     | "public" { $$ = CYNew CYIdentifier("public"); }
     | "set" { $$ = CYNew CYIdentifier("set"); }
     | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
+    | "target" { $$ = CYNew CYIdentifier("target"); }
     | "throws" { $$ = CYNew CYIdentifier("throws"); }
     | "transient" { $$ = CYNew CYIdentifier("transient"); }
     | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
@@ -998,8 +1063,8 @@ MemberExpression
     ;
 
 SuperProperty
-    : LexSetRegExp "!super" "[" Expression "]" { $$ = CYNew CYSuperAccess($4); }
-    | LexSetRegExp "!super" "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($4)); }
+    : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "[" Expression "]" { $$ = CYNew CYSuperAccess($5); }
+    | LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($5)); }
     ;
 
 MetaProperty
@@ -1016,18 +1081,18 @@ NewExpression
     ;
 
 CallExpression_
-    : MemberExpression
-    | CallExpression
+    : MemberExpression { $$ = $1; }
+    | CallExpression { $$ = $1; }
     ;
 
 CallExpression
-    : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
+    : CallExpression_ Arguments { if (!$1->Eval()) $$ = CYNew CYCall($1, $2); else $$ = CYNew CYEval($2); }
     | SuperCall { $$ = $1; }
     | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
     ;
 
 SuperCall
-    : LexSetRegExp "!super" Arguments { $$ = CYNew CYSuperCall($3); }
+    : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } Arguments { $$ = CYNew CYSuperCall($4); }
     ;
 
 Arguments
@@ -1077,7 +1142,7 @@ UnaryExpression_
     ;
 
 UnaryExpression
-    : %prec "" PostfixExpression { $$ = $1; }
+    : %prec "" PostfixExpression LexOpenBrace { $$ = $1; }
     | LexSetRegExp UnaryExpression_ { $$ = $2; }
     ;
 /* }}} */
@@ -1152,28 +1217,46 @@ LogicalORExpression
     ;
 /* }}} */
 /* 12.13 Conditional Operator ( ? : ) {{{ */
+@begin ObjectiveC
+ConditionalExpressionClassic
+    : LogicalORExpression { $$ = $1; }
+    | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpressionClassic { $$ = CYNew CYCondition($1, $4, $7); }
+    ;
+@end
+
 ConditionalExpression
     : LogicalORExpression { $$ = $1; }
     | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
     ;
 /* }}} */
 /* 12.14 Assignment Operators {{{ */
+LeftHandSideAssignment
+    : LeftHandSideExpression "=" { $$ = CYNew CYAssign($1, NULL); }
+    | LeftHandSideExpression "*=" { $$ = CYNew CYMultiplyAssign($1, NULL); }
+    | LeftHandSideExpression "/=" { $$ = CYNew CYDivideAssign($1, NULL); }
+    | LeftHandSideExpression "%=" { $$ = CYNew CYModulusAssign($1, NULL); }
+    | LeftHandSideExpression "+=" { $$ = CYNew CYAddAssign($1, NULL); }
+    | LeftHandSideExpression "-=" { $$ = CYNew CYSubtractAssign($1, NULL); }
+    | LeftHandSideExpression "<<=" { $$ = CYNew CYShiftLeftAssign($1, NULL); }
+    | LeftHandSideExpression ">>=" { $$ = CYNew CYShiftRightSignedAssign($1, NULL); }
+    | LeftHandSideExpression ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($1, NULL); }
+    | LeftHandSideExpression "&=" { $$ = CYNew CYBitwiseAndAssign($1, NULL); }
+    | LeftHandSideExpression "^=" { $$ = CYNew CYBitwiseXOrAssign($1, NULL); }
+    | LeftHandSideExpression "|=" { $$ = CYNew CYBitwiseOrAssign($1, NULL); }
+    ;
+
+@begin ObjectiveC
+AssignmentExpressionClassic
+    : ConditionalExpressionClassic { $$ = $1; }
+    | LeftHandSideAssignment AssignmentExpressionClassic { $1->SetRight($2); $$ = $1; }
+    ;
+@end
+
 AssignmentExpression
     : ConditionalExpression { $$ = $1; }
     | LexSetRegExp YieldExpression { $$ = $2; }
     | ArrowFunction { $$ = $1; }
-    | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
-    | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
-    | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
-    | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
-    | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
-    | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
-    | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
-    | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
-    | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
-    | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
-    | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
-    | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
+    | LeftHandSideAssignment AssignmentExpression { $1->SetRight($2); $$ = $1; }
     ;
 
 AssignmentExpressionOpt
@@ -1267,13 +1350,17 @@ StatementListItem
     ;
 /* }}} */
 /* 13.3 Let and Const Declarations {{{ */
+LexicalDeclaration_
+    : LetOrConst BindingList { $$ = CYNew CYLet($1, $2); }
+    ;
+
 LexicalDeclaration
-    : LetOrConst BindingList Terminator { $$ = CYNew CYVar($2); }
+    : LexicalDeclaration_ Terminator { $$ = $1; }
     ;
 
 LetOrConst
-    : "let"
-    | "const"
+    : "let" { $$ = false; }
+    | "const" { $$ = true; }
     ;
 
 BindingList_
@@ -1291,8 +1378,12 @@ LexicalBinding
     ;
 /* }}} */
 /* 13.3.2 Variable Statement {{{ */
+VariableStatement_
+    : Var_ VariableDeclarationList { $$ = CYNew CYVar($2); }
+    ;
+
 VariableStatement
-    : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
+    : VariableStatement_ Terminator { $$ = $1; }
     ;
 
 VariableDeclarationList_
@@ -1361,8 +1452,11 @@ EmptyStatement
     ;
 /* }}} */
 /* 13.5 Expression Statement {{{ */
+ExpressionStatement_
+    : Expression { $$ = CYNew CYExpress($1); }
+
 ExpressionStatement
-    : Expression Terminator { $$ = CYNew CYExpress($1); }
+    : ExpressionStatement_ Terminator { $$ = $1; }
     ;
 /* }}} */
 /* 13.6 The if Statement {{{ */
@@ -1379,25 +1473,27 @@ IfStatement
 IterationStatement
     : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
     | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
-    | "for" "(" LexPushInOn ForStatementInitializer ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
+    | "for" "(" LexPushInOn ForStatementInitializer LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $6, $8, $10); }
+    | "for" "(" LexPushInOn LexSetRegExp Var_ BindingIdentifier Initializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForInitialized(CYNew CYDeclaration($6, $7), $10, $12); }
     | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
-    | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
+    | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn AssignmentExpression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
     ;
 
 ForStatementInitializer
-    : ExpressionOpt { $$ = $1; }
-    | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
-    | LexSetRegExp LexicalDeclaration { CYNOT(@$); }
+    : LexSetRegExp EmptyStatement { $$ = $2; }
+    | ExpressionStatement_ ";" { $$ = $1; }
+    | LexSetRegExp VariableStatement_ ";" { $$ = $2; }
+    | LexSetRegExp LexicalDeclaration_ ";" { $$ = $2; }
     ;
 
 ForInStatementInitializer
     : LeftHandSideExpression { $$ = $1; }
-    | LexSetRegExp Var_ ForBinding { $$ = $3; }
+    | LexSetRegExp Var_ ForBinding { $$ = CYNew CYForVariable($3); }
     | LexSetRegExp ForDeclaration { $$ = $2; }
     ;
 
 ForDeclaration
-    : LetOrConst ForBinding { $$ = $2; }
+    : LetOrConst ForBinding { $$ = CYNew CYForLexical($1, $2); }
     ;
 
 ForBinding
@@ -1555,8 +1651,12 @@ FunctionStatementList
     ;
 /* }}} */
 /* 14.2 Arrow Function Definitions {{{ */
+LexEqualRight
+    : { CYLIN(EqualRight); }
+    ;
+
 ArrowFunction
-    : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
+    : LexSetRegExp ArrowParameters LexEqualRight "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $6); }
     ;
 
 ArrowParameters
@@ -1603,7 +1703,7 @@ Yield
     ;
 
 YieldExpression
-    : Yield LexSetRegExp "\n" { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
+    : Yield LexSetRegExp NewLineOpt { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
     | Yield AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldValue($2); */ }
     | Yield LexSetRegExp YieldStar AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($4); */ }
     ;
@@ -1869,7 +1969,7 @@ ClassSuperOpt
     ;
 
 ImplementationFieldListOpt
-    : TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($1, $3); }
+    : LexSetRegExp TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($2, $4); }
     | LexSetRegExp { $$ = NULL; }
     ;
 
@@ -1948,7 +2048,7 @@ Statement__
 /* }}} */
 /* Cycript (Objective-C): Send Message {{{ */
 VariadicCall
-    : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
+    : "," AssignmentExpressionClassic VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
     | { $$ = NULL; }
     ;
 
@@ -1963,7 +2063,7 @@ SelectorCall_
     ;
 
 SelectorCall
-    : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
+    : SelectorWordOpt ":" AssignmentExpressionClassic SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
     ;
 
 SelectorList
@@ -1972,8 +2072,8 @@ SelectorList
     ;
 
 MessageExpression
-    : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
-    | "[" LexPushInOff LexSetRegExp "!super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
+    : "[" LexPushInOff AssignmentExpressionClassic { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
+    | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
     ;
 
 SelectorExpression_
@@ -2284,15 +2384,6 @@ IterationStatement
     : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
     ;
 /* }}} */
-/* JavaScript FTL: let Statements {{{ */
-LetStatement
-    : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
-    ;
-
-Statement__
-    : LetStatement
-    ;
-/* }}} */
 
 /* JavaScript FTW: Array Comprehensions {{{ */
 PrimaryExpression
@@ -2314,8 +2405,8 @@ ComprehensionTail
     ;
 
 ComprehensionFor
-    : "for" "(" LexPushInOn LexicalBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
-    | "for" "(" LexPushInOn LexicalBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($4, $7); }
+    : "for" "(" LexPushInOn ForBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
+    | "for" "(" LexPushInOn ForBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($4, $7); }
     ;
 
 ComprehensionIf
@@ -2350,7 +2441,11 @@ RubyProcParameters
 
 RubyProcParametersOpt
     : RubyProcParameters { $$ = $1; }
-    | { $$ = NULL; }
+    | LexSetRegExp { $$ = NULL; }
+    ;
+
+LexOpenBrace
+    : { CYLIN(OpenBrace); }
     ;
 
 RubyProcExpression
@@ -2362,7 +2457,7 @@ PrimaryExpression
     ;
 
 PostfixExpression
-    : PostfixExpression RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
+    : PostfixExpression LexOpenBrace RubyProcExpression { $$ = CYNew CYRubyBlock($1, $3); }
     ;
 /* }}} */