]> git.saurik.com Git - cycript.git/commitdiff
Replace \n-tokens with LexNewLine and held tokens.
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 18 Dec 2015 12:50:58 +0000 (04:50 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 18 Dec 2015 12:50:58 +0000 (04:50 -0800)
Driver.cpp
Driver.hpp
Makefile.am
Makefile.in
Parser.ypp.in

index fef1eb124d118dfd38a9604903910b868fb8cea8..788afee05c58a8546c93c16fcd4cdc73b2e2f35e 100644 (file)
@@ -26,9 +26,8 @@ bool CYParser(CYPool &pool, bool debug);
 
 CYDriver::CYDriver(CYPool &pool, std::istream &data, const std::string &filename) :
     pool_(pool),
 
 CYDriver::CYDriver(CYPool &pool, std::istream &data, const std::string &filename) :
     pool_(pool),
-    newline_(NewLineNone),
+    newline_(false),
     last_(false),
     last_(false),
-    next_(false),
     data_(data),
     debug_(0),
     strict_(false),
     data_(data),
     debug_(0),
     strict_(false),
index f0d27322877133ec4e548be4eda98e1359c9c4b6..bbce9fd4ac1bee3572d3c312fa60528f00c14b93 100644 (file)
@@ -39,7 +39,6 @@ struct CYScript;
 struct CYWord;
 
 enum CYMark {
 struct CYWord;
 
 enum CYMark {
-    CYMarkIgnore,
     CYMarkScript,
     CYMarkModule,
 };
     CYMarkScript,
     CYMarkModule,
 };
@@ -60,17 +59,12 @@ class _visible CYDriver {
 
     std::stack<CYClassTail *> class_;
 
 
     std::stack<CYClassTail *> class_;
 
-    enum {
-        NewLineNone,
-        NewLineLast,
-        NewLineHere,
-    } newline_;
-
+    CYMark mark_;
+    int hold_;
+    bool newline_;
     bool last_;
     bool last_;
-    bool next_;
 
     std::istream &data_;
 
     std::istream &data_;
-    CYMark mark_;
 
     int debug_;
     bool strict_;
 
     int debug_;
     bool strict_;
index 0f567cbdf2b4c97959f46905ab0186477ccf9e40..eb0c8843f8e7d1c2b5c61d39983941a5b3c9e368 100644 (file)
@@ -111,11 +111,14 @@ Scanner.cpp: Scanner.lpp
        ! grep -F ': warning, ' Scanner.output || true
 
 Scanner.lo: Parser.hpp IdentifierStart.h IdentifierContinue.h
        ! grep -F ': warning, ' Scanner.output || true
 
 Scanner.lo: Parser.hpp IdentifierStart.h IdentifierContinue.h
+Parser.lo: Parser.hpp
+Parser.cpp: Parser.hpp
 
 CLEANFILES += Parser.cpp Parser.hpp stack.hh Parser.output
 
 CLEANFILES += Parser.cpp Parser.hpp stack.hh Parser.output
-Parser.cpp Parser.hpp stack.hh Parser.output: Parser.ypp
+Parser.hpp: Parser.ypp
        $(BISON) -v --report=state -Werror -o Parser.cpp $<
        ! grep -n '^State [0-9]* conflicts:' Parser.output
        ! grep -n '^ *.* *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output | grep -v '$$default'
        ! grep -n '^ *$$default *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output -B 2 | grep 'shift, and go to state [0-9]*$$'
        ! grep -n '^ *$$default *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output -B 2 | grep -v '$$default' | grep 'reduce using rule [0-9]* ([^)]*)$$'
        $(BISON) -v --report=state -Werror -o Parser.cpp $<
        ! grep -n '^State [0-9]* conflicts:' Parser.output
        ! grep -n '^ *.* *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output | grep -v '$$default'
        ! grep -n '^ *$$default *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output -B 2 | grep 'shift, and go to state [0-9]*$$'
        ! grep -n '^ *$$default *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output -B 2 | grep -v '$$default' | grep 'reduce using rule [0-9]* ([^)]*)$$'
+       perl -pi -e 's/yytranslate_ \(yylex \(/(yylex_ (/g' Parser.cpp
index 3ca299b7c0560a7f691f63bd50593a705eef04c7..9f07a05defde19d8872aeda5f8d9819d5b910e36 100644 (file)
@@ -1315,12 +1315,15 @@ Scanner.cpp: Scanner.lpp
        ! grep -F ': warning, ' Scanner.output || true
 
 Scanner.lo: Parser.hpp IdentifierStart.h IdentifierContinue.h
        ! grep -F ': warning, ' Scanner.output || true
 
 Scanner.lo: Parser.hpp IdentifierStart.h IdentifierContinue.h
-Parser.cpp Parser.hpp stack.hh Parser.output: Parser.ypp
+Parser.lo: Parser.hpp
+Parser.cpp: Parser.hpp
+Parser.hpp: Parser.ypp
        $(BISON) -v --report=state -Werror -o Parser.cpp $<
        ! grep -n '^State [0-9]* conflicts:' Parser.output
        ! grep -n '^ *.* *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output | grep -v '$$default'
        ! grep -n '^ *$$default *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output -B 2 | grep 'shift, and go to state [0-9]*$$'
        ! grep -n '^ *$$default *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output -B 2 | grep -v '$$default' | grep 'reduce using rule [0-9]* ([^)]*)$$'
        $(BISON) -v --report=state -Werror -o Parser.cpp $<
        ! grep -n '^State [0-9]* conflicts:' Parser.output
        ! grep -n '^ *.* *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output | grep -v '$$default'
        ! grep -n '^ *$$default *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output -B 2 | grep 'shift, and go to state [0-9]*$$'
        ! grep -n '^ *$$default *reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Parser.output -B 2 | grep -v '$$default' | grep 'reduce using rule [0-9]* ([^)]*)$$'
+       perl -pi -e 's/yytranslate_ \(yylex \(/(yylex_ (/g' Parser.cpp
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
index 148d2d0622ecbdacc68ee66f96f7ecf041a9a080..5780173c0376ce22a547c7d0e721002c1cc54cd4 100644 (file)
@@ -113,25 +113,13 @@ int cylex(YYSTYPE *, CYLocation *, void *);
 
 %code {
 
 
 %code {
 
-typedef cy::parser::token tk;
-
 #undef yylex
 #undef yylex
-_finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) {
-    if (driver.mark_ == CYMarkIgnore);
-    else if (driver.mark_ == CYMarkScript) {
-        driver.mark_ = CYMarkIgnore;
-        return cy::parser::token::MarkScript;
-    } else if (driver.mark_ == CYMarkModule) {
-        driver.mark_ = CYMarkIgnore;
-        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;
+typedef cy::parser::token tk;
 
 
+_finline int cylex_(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) {
+    driver.newline_ = false;
+  lex:
     YYSTYPE data;
     int token(cylex(&data, location, driver.scanner_));
     *semantic = data.semantic_;
     YYSTYPE data;
     int token(cylex(&data, location, driver.scanner_));
     *semantic = data.semantic_;
@@ -161,19 +149,27 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
         break;
 
         case tk::NewLine:
         break;
 
         case tk::NewLine:
-            driver.newline_ = CYDriver::NewLineHere;
-            if (!driver.next_)
-                goto lex;
+            driver.newline_ = true;
+            goto lex;
         break;
     }
 
         break;
     }
 
-    driver.next_ = false;
     return token;
 }
 
     return token;
 }
 
+#define yylex_(semantic, location, driver) ({ \
+    int type; \
+    if (driver.hold_ == cy::parser::empty_symbol) \
+        type = yytranslate_(cylex_(semantic, location, driver)); \
+    else { \
+        type = driver.hold_; \
+        driver.hold_ = cy::parser::empty_symbol; \
+    } \
+type; })
+
 #define CYLEX() do if (yyla.empty()) { \
     YYCDEBUG << "Mapping a token: "; \
 #define CYLEX() do if (yyla.empty()) { \
     YYCDEBUG << "Mapping a token: "; \
-    yyla.type = yytranslate_(yylex(&yyla.value, &yyla.location, driver)); \
+    yyla.type = yylex_(&yyla.value, &yyla.location, driver); \
     YY_SYMBOL_PRINT("Next token is", yyla); \
 } while (false)
 
     YY_SYMBOL_PRINT("Next token is", yyla); \
 } while (false)
 
@@ -183,12 +179,6 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
         yyla.type = yytranslate_(token::to); \
 } while (false)
 
         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; \
 #define CYERR(location, message) do { \
     error(location, message); \
     YYABORT; \
@@ -215,6 +205,15 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 
 %initial-action {
     @$.begin.filename = @$.end.filename = &driver.filename_;
 
 %initial-action {
     @$.begin.filename = @$.end.filename = &driver.filename_;
+
+    switch (driver.mark_) {
+        case CYMarkScript:
+            driver.hold_ = yytranslate_(token::MarkScript);
+            break;
+        case CYMarkModule:
+            driver.hold_ = yytranslate_(token::MarkModule);
+            break;
+    }
 };
 
 %locations
 };
 
 %locations
@@ -267,14 +266,12 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %token EqualEqual "=="
 %token EqualEqualEqual "==="
 %token EqualRight "=>"
 %token EqualEqual "=="
 %token EqualEqualEqual "==="
 %token EqualRight "=>"
-%token EqualRight_ "\n=>"
 %token Exclamation "!"
 %token ExclamationEqual "!="
 %token ExclamationEqualEqual "!=="
 %token Hyphen "-"
 %token HyphenEqual "-="
 %token HyphenHyphen "--"
 %token Exclamation "!"
 %token ExclamationEqual "!="
 %token ExclamationEqualEqual "!=="
 %token Hyphen "-"
 %token HyphenEqual "-="
 %token HyphenHyphen "--"
-%token HyphenHyphen_ "\n--"
 %token HyphenRight "->"
 %token Left "<"
 %token LeftEqual "<="
 %token HyphenRight "->"
 %token Left "<"
 %token LeftEqual "<="
@@ -290,7 +287,6 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %token Plus "+"
 %token PlusEqual "+="
 %token PlusPlus "++"
 %token Plus "+"
 %token PlusEqual "+="
 %token PlusPlus "++"
-%token PlusPlus_ "\n++"
 %token Right ">"
 %token RightEqual ">="
 %token RightRight ">>"
 %token Right ">"
 %token RightEqual ">="
 %token RightRight ">>"
@@ -315,8 +311,7 @@ _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CY
 %token CloseParen ")"
 
 %token OpenBrace "{"
 %token CloseParen ")"
 
 %token OpenBrace "{"
-%token OpenBrace_ "\n{"
-%token OpenBrace__ ";{"
+%token OpenBrace_ ";{"
 %token OpenBrace_let "let {"
 %token CloseBrace "}"
 
 %token OpenBrace_let "let {"
 %token CloseBrace "}"
 
@@ -726,7 +721,7 @@ LexPushYieldOff: { driver.yield_.push(false); };
 LexPopYield: { driver.yield_.pop(); };
 
 LexNewLine
 LexPopYield: { driver.yield_.pop(); };
 
 LexNewLine
-    : { CYMPT(@$); driver.next_ = true; }
+    : { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); if (driver.newline_) { driver.hold_ = yyla.type; yyla.type = yytranslate_(cy::parser::token::NewLine); } }
     ;
 
 LexNoStar
     ;
 
 LexNoStar
@@ -734,7 +729,7 @@ LexNoStar
     ;
 
 LexNoBrace
     ;
 
 LexNoBrace
-    : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
+    : { CYMAP(OpenBrace_, OpenBrace); }
     ;
 
 LexNoClass
     ;
 
 LexNoClass
@@ -750,11 +745,6 @@ LexSetStatement
     ;
 /* }}} */
 /* Virtual Tokens {{{ */
     ;
 /* }}} */
 /* Virtual Tokens {{{ */
-BRACE
-    : "{"
-    | "\n{"
-    ;
-
 Var_
     : "var"
     ;
 Var_
     : "var"
     ;
@@ -768,11 +758,6 @@ IdentifierName
     | "instanceof" { $$ = CYNew CYWord("instanceof"); }
     ;
 
     | "instanceof" { $$ = CYNew CYWord("instanceof"); }
     ;
 
-NewLineOpt
-    : "\n"
-    |
-    ;
-
 Word
     : IdentifierNoOf[pass] { $$ = $pass; }
     | "auto" { $$ = CYNew CYWord("auto"); }
 Word
     : IdentifierNoOf[pass] { $$ = $pass; }
     | "auto" { $$ = CYNew CYWord("auto"); }
@@ -813,8 +798,6 @@ Word
     | "while" { $$ = CYNew CYWord("while"); }
     | "with" { $$ = CYNew CYWord("with"); }
     | "yield" { $$ = CYNew CYIdentifier("yield"); }
     | "while" { $$ = CYNew CYWord("while"); }
     | "with" { $$ = CYNew CYWord("with"); }
     | "yield" { $$ = CYNew CYIdentifier("yield"); }
-
-    | Yield LexOf NewLineOpt { $$ = CYNew CYIdentifier("yield"); }
     ;
 
 @begin ObjectiveC
     ;
 
 @begin ObjectiveC
@@ -858,7 +841,7 @@ TerminatorSoft
 
 Terminator
     : ";"
 
 Terminator
     : ";"
-    | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && driver.newline_ == CYDriver::NewLineNone) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi
+    | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi
     ;
 
 TerminatorOpt
     ;
 
 TerminatorOpt
@@ -1011,7 +994,7 @@ ElementListOpt
 /* }}} */
 /* 12.2.6 Object Initializer {{{ */
 ObjectLiteral
 /* }}} */
 /* 12.2.6 Object Initializer {{{ */
 ObjectLiteral
-    : BRACE PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYObject($properties); }
+    : "{" PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYObject($properties); }
     ;
 
 PropertyDefinitionList_
     ;
 
 PropertyDefinitionList_
@@ -1149,19 +1132,15 @@ AccessExpression
     ;
 
 LeftHandSideExpression
     ;
 
 LeftHandSideExpression
-    : AccessExpression[pass] LexCrement { $$ = $pass; }
+    : AccessExpression[pass] LexNewLine { $$ = $pass; }
     | IndirectExpression[pass] { $$ = $pass; }
     ;
 /* }}} */
 /* 12.4 Postfix Expressions {{{ */
     | IndirectExpression[pass] { $$ = $pass; }
     ;
 /* }}} */
 /* 12.4 Postfix Expressions {{{ */
-LexCrement
-    : { CYLIN(PlusPlus); CYLIN(HyphenHyphen); }
-    ;
-
 PostfixExpression
 PostfixExpression
-    : AccessExpression[lhs] LexCrement { $$ = $lhs; }
-    | AccessExpression[lhs] LexCrement "++" { $$ = CYNew CYPostIncrement($lhs); }
-    | AccessExpression[lhs] LexCrement "--" { $$ = CYNew CYPostDecrement($lhs); }
+    : AccessExpression[lhs] LexNewLine { $$ = $lhs; }
+    | AccessExpression[lhs] LexNewLine "++" { $$ = CYNew CYPostIncrement($lhs); }
+    | AccessExpression[lhs] LexNewLine "--" { $$ = CYNew CYPostDecrement($lhs); }
     ;
 /* }}} */
 /* 12.5 Unary Operators {{{ */
     ;
 /* }}} */
 /* 12.5 Unary Operators {{{ */
@@ -1170,9 +1149,7 @@ UnaryExpression_
     | "void" UnaryExpression[rhs] { $$ = CYNew CYVoid($rhs); }
     | "typeof" UnaryExpression[rhs] { $$ = CYNew CYTypeOf($rhs); }
     | "++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); }
     | "void" UnaryExpression[rhs] { $$ = CYNew CYVoid($rhs); }
     | "typeof" UnaryExpression[rhs] { $$ = CYNew CYTypeOf($rhs); }
     | "++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); }
-    | "\n++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); }
     | "--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); }
     | "--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); }
-    | "\n--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); }
     | "+" UnaryExpression[rhs] { $$ = CYNew CYAffirm($rhs); }
     | "-" UnaryExpression[rhs] { $$ = CYNew CYNegate($rhs); }
     | "~" UnaryExpression[rhs] { $$ = CYNew CYBitwiseNot($rhs); }
     | "+" UnaryExpression[rhs] { $$ = CYNew CYAffirm($rhs); }
     | "-" UnaryExpression[rhs] { $$ = CYNew CYNegate($rhs); }
     | "~" UnaryExpression[rhs] { $$ = CYNew CYBitwiseNot($rhs); }
@@ -1180,7 +1157,8 @@ UnaryExpression_
     ;
 
 UnaryExpression
     ;
 
 UnaryExpression
-    : PostfixExpression[expression] LexOpenBrace { $$ = $expression; }
+    : PostfixExpression[expression] { $$ = $expression; }
+    | PostfixExpression[expression] "\n" { $$ = $expression; }
     | UnaryExpression_[pass] { $$ = $pass; }
     ;
 /* }}} */
     | UnaryExpression_[pass] { $$ = $pass; }
     ;
 /* }}} */
@@ -1366,7 +1344,7 @@ BlockStatement
     ;
 
 Block
     ;
 
 Block
-    : BRACE StatementListOpt[code] "}" { $$ = $code; }
+    : "{" StatementListOpt[code] "}" { $$ = $code; }
     ;
 
 StatementList
     ;
 
 StatementList
@@ -1533,7 +1511,7 @@ ForStatementInitializer
     ;
 
 ForInStatementInitializer
     ;
 
 ForInStatementInitializer
-    : LexLet LexOf AccessExpression[pass] LexCrement { $$ = $pass; }
+    : LexLet LexOf AccessExpression[pass] LexNewLine { $$ = $pass; }
     | LexLet LexOf IndirectExpression[pass] { $$ = $pass; }
     | LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); }
     | ForDeclaration[pass] { $$ = $pass; }
     | LexLet LexOf IndirectExpression[pass] { $$ = $pass; }
     | LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); }
     | ForDeclaration[pass] { $$ = $pass; }
@@ -1549,33 +1527,25 @@ ForBinding
     ;
 /* }}} */
 /* 13.8 The continue Statement {{{ */
     ;
 /* }}} */
 /* 13.8 The continue Statement {{{ */
-Continue
-    : "continue" LexNewLine
-    ;
-
 ContinueStatement
 ContinueStatement
-    : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
-    | Continue Identifier[label] Terminator { $$ = CYNew CYContinue($label); }
+    : "continue" LexNewLine TerminatorSoft { $$ = CYNew CYContinue(NULL); }
+    | "continue" LexNewLine Identifier[label] Terminator { $$ = CYNew CYContinue($label); }
     ;
 /* }}} */
 /* 13.9 The break Statement {{{ */
     ;
 /* }}} */
 /* 13.9 The break Statement {{{ */
-Break
-    : "break" LexNewLine
-    ;
-
 BreakStatement
 BreakStatement
-    : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
-    | Break Identifier[label] Terminator { $$ = CYNew CYBreak($label); }
+    : "break" LexNewLine TerminatorSoft { $$ = CYNew CYBreak(NULL); }
+    | "break" LexNewLine Identifier[label] Terminator { $$ = CYNew CYBreak($label); }
     ;
 /* }}} */
 /* 13.10 The return Statement {{{ */
 Return
     ;
 /* }}} */
 /* 13.10 The return Statement {{{ */
 Return
-    : "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); } LexNewLine
+    : "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); }
     ;
 
 ReturnStatement
     ;
 
 ReturnStatement
-    : Return LexOf TerminatorSoft { $$ = CYNew CYReturn(NULL); }
-    | Return Expression[value] Terminator { $$ = CYNew CYReturn($value); }
+    : Return LexNewLine LexOf TerminatorSoft { $$ = CYNew CYReturn(NULL); }
+    | Return LexNewLine Expression[value] Terminator { $$ = CYNew CYReturn($value); }
     ;
 /* }}} */
 /* 13.11 The with Statement {{{ */
     ;
 /* }}} */
 /* 13.11 The with Statement {{{ */
@@ -1589,7 +1559,7 @@ SwitchStatement
     ;
 
 CaseBlock
     ;
 
 CaseBlock
-    : BRACE CaseClausesOpt[clauses] "}" { $$ = $clauses; }
+    : "{" CaseClausesOpt[clauses] "}" { $$ = $clauses; }
     ;
 
 CaseClause
     ;
 
 CaseClause
@@ -1618,13 +1588,9 @@ LabelledItem
     ;
 /* }}} */
 /* 13.14 The throw Statement {{{ */
     ;
 /* }}} */
 /* 13.14 The throw Statement {{{ */
-Throw
-    : "throw" LexNewLine
-    ;
-
 ThrowStatement
 ThrowStatement
-    : Throw[throw] LexOf TerminatorSoft { CYERR(@throw, "throw without exception"); }
-    | Throw Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); }
+    : "throw"[throw] LexNewLine LexOf TerminatorSoft { CYERR(@throw, "throw without exception"); }
+    | "throw" LexNewLine Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); }
     ;
 /* }}} */
 /* 13.15 The try Statement {{{ */
     ;
 /* }}} */
 /* 13.15 The try Statement {{{ */
@@ -1655,11 +1621,11 @@ DebuggerStatement
 
 /* 14.1 Function Definitions {{{ */
 FunctionDeclaration
 
 /* 14.1 Function Definitions {{{ */
 FunctionDeclaration
-    : ";function" BindingIdentifier[name] "(" FormalParameters[parameters] ")" BRACE LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionStatement($name, $parameters, $code); }
+    : ";function" BindingIdentifier[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionStatement($name, $parameters, $code); }
     ;
 
 FunctionExpression
     ;
 
 FunctionExpression
-    : "function" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" BRACE LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionExpression($name, $parameters, $code); }
+    : "function" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionExpression($name, $parameters, $code); }
     ;
 
 StrictFormalParameters
     ;
 
 StrictFormalParameters
@@ -1698,12 +1664,8 @@ FunctionStatementList
     ;
 /* }}} */
 /* 14.2 Arrow Function Definitions {{{ */
     ;
 /* }}} */
 /* 14.2 Arrow Function Definitions {{{ */
-LexEqualRight
-    : { CYLIN(EqualRight); }
-    ;
-
 ArrowFunction
 ArrowFunction
-    : ArrowParameters[parameters] LexEqualRight "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); }
+    : ArrowParameters[parameters] LexNewLine "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); }
     ;
 
 ArrowParameters
     ;
 
 ArrowParameters
@@ -1718,10 +1680,10 @@ ConciseBody
 /* }}} */
 /* 14.3 Method Definitions {{{ */
 MethodDefinition
 /* }}} */
 /* 14.3 Method Definitions {{{ */
 MethodDefinition
-    : PropertyName[name] "(" StrictFormalParameters[parameters] ")" BRACE FunctionBody[code] "}" { $$ = CYNew CYPropertyMethod($name, $parameters, $code); }
+    : PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyMethod($name, $parameters, $code); }
     | GeneratorMethod[pass] { $$ = $pass; }
     | GeneratorMethod[pass] { $$ = $pass; }
-    | "get" PropertyName[name] "(" ")" BRACE FunctionBody[code] "}" { $$ = CYNew CYPropertyGetter($name, $code); }
-    | "set" PropertyName[name] "(" PropertySetParameterList[parameter] ")" BRACE FunctionBody[code] "}" { $$ = CYNew CYPropertySetter($name, $parameter, $code); }
+    | "get" PropertyName[name] "(" ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyGetter($name, $code); }
+    | "set" PropertyName[name] "(" PropertySetParameterList[parameter] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertySetter($name, $parameter, $code); }
     ;
 
 PropertySetParameterList
     ;
 
 PropertySetParameterList
@@ -1730,15 +1692,15 @@ PropertySetParameterList
 /* }}} */
 /* 14.4 Generator Function Definitions {{{ */
 GeneratorMethod
 /* }}} */
 /* 14.4 Generator Function Definitions {{{ */
 GeneratorMethod
-    : "*" PropertyName[name] "(" StrictFormalParameters[parameters] ")" BRACE GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($name, $parameters, $code); */ }
+    : "*" PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($name, $parameters, $code); */ }
     ;
 
 GeneratorDeclaration
     ;
 
 GeneratorDeclaration
-    : ";function" LexOf "*" BindingIdentifier[name] "(" FormalParameters[code] ")" BRACE GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($name, $parameters, $code); */ }
+    : ";function" LexOf "*" BindingIdentifier[name] "(" FormalParameters[code] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($name, $parameters, $code); */ }
     ;
 
 GeneratorExpression
     ;
 
 GeneratorExpression
-    : "function" LexOf "*" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" BRACE GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($name, $parameters, $code); */ }
+    : "function" LexOf "*" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($name, $parameters, $code); */ }
     ;
 
 GeneratorBody
     ;
 
 GeneratorBody
@@ -1750,7 +1712,8 @@ Yield
     ;
 
 YieldExpression
     ;
 
 YieldExpression
-    : Yield LexOf NewLineOpt { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
+    : Yield LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
+    | Yield LexOf "\n" { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
     | Yield AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ }
     | Yield LexOf YieldStar AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ }
     ;
     | Yield AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ }
     | Yield LexOf YieldStar AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ }
     ;
@@ -1765,7 +1728,7 @@ ClassExpression
     ;
 
 ClassTail
     ;
 
 ClassTail
-    : ClassHeritageOpt[tail] { driver.class_.push($tail); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $tail; }
+    : ClassHeritageOpt[tail] { driver.class_.push($tail); } "{" LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $tail; }
     ;
 
 ClassHeritage
     ;
 
 ClassHeritage
@@ -1868,7 +1831,7 @@ NameSpaceImport
     ;
 
 NamedImports
     ;
 
 NamedImports
-    : BRACE ImportsListOpt "}"
+    : "{" ImportsListOpt "}"
     ;
 
 FromClause
     ;
 
 FromClause
@@ -2021,7 +1984,7 @@ ImplementationFieldListOpt
     ;
 
 ImplementationFields
     ;
 
 ImplementationFields
-    : BRACE ImplementationFieldListOpt[fields] "}" { $$ = $fields; }
+    : "{" ImplementationFieldListOpt[fields] "}" { $$ = $fields; }
     ;
 
 MessageScope
     ;
 
 MessageScope
@@ -2053,7 +2016,7 @@ MessageParameters
     ;
 
 ClassMessageDeclaration
     ;
 
 ClassMessageDeclaration
-    : MessageScope[instance] TypeOpt[type] MessageParameters[parameters] BRACE LexPushSuperOn FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYMessage($instance, $type, $parameters, $code); }
+    : MessageScope[instance] TypeOpt[type] MessageParameters[parameters] "{" LexPushSuperOn FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYMessage($instance, $type, $parameters, $code); }
     ;
 
 ClassMessageDeclarationListOpt
     ;
 
 ClassMessageDeclarationListOpt
@@ -2180,7 +2143,7 @@ PrimaryExpression
 /* }}} */
 /* Cycript (Objective-C): Block Expressions {{{ */
 PrimaryExpression
 /* }}} */
 /* Cycript (Objective-C): Block Expressions {{{ */
 PrimaryExpression
-    : "^" TypedIdentifier[type] { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); } BRACE FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); }
+    : "^" TypedIdentifier[type] { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); } "{" FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); }
     ;
 /* }}} */
 /* Cycript (Objective-C): Instance Literals {{{ */
     ;
 /* }}} */
 /* Cycript (Objective-C): Instance Literals {{{ */
@@ -2231,7 +2194,7 @@ TypedParameterListOpt
     ;
 
 PrimaryExpression
     ;
 
 PrimaryExpression
-    : "[" LexOf "&" "]" "(" TypedParameterListOpt[parameters] ")" "->" TypedIdentifier[type] BRACE FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); }
+    : "[" LexOf "&" "]" "(" TypedParameterListOpt[parameters] ")" "->" TypedIdentifier[type] "{" FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); }
     ;
 /* }}} */
 /* Cycript (C): Type Definitions {{{ */
     ;
 /* }}} */
 /* Cycript (C): Type Definitions {{{ */
@@ -2353,7 +2316,7 @@ XMLTagContent
     ;
 
 XMLExpression
     ;
 
 XMLExpression
-    : BRACE LexPushRegExp Expression LexPop "}"
+    : "{" LexPushRegExp Expression LexPop "}"
     ;
 
 XMLTagName
     ;
 
 XMLTagName
@@ -2495,20 +2458,16 @@ RubyProcParametersOpt
     | { $$ = NULL; }
     ;
 
     | { $$ = NULL; }
     ;
 
-LexOpenBrace
-    : { CYLIN(OpenBrace); }
-    ;
-
 RubyProcExpression
     : "{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
     ;
 
 PrimaryExpression
 RubyProcExpression
     : "{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
     ;
 
 PrimaryExpression
-    : BRACE RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
+    : "{" RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
     ;
 
 PostfixExpression
     ;
 
 PostfixExpression
-    : PostfixExpression[lhs] LexOpenBrace RubyProcExpression[rhs] { $$ = CYNew CYRubyBlock($lhs, $rhs); }
+    : PostfixExpression[lhs] RubyProcExpression[rhs] LexNewLine { $$ = CYNew CYRubyBlock($lhs, $rhs); }
     ;
 /* }}} */
 
     ;
 /* }}} */