]> git.saurik.com Git - cycript.git/commitdiff
Add support for ECMA6 for-of iteration statements.
authorJay Freeman (saurik) <saurik@saurik.com>
Thu, 7 Jun 2012 04:04:20 +0000 (21:04 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 7 Jun 2012 04:04:20 +0000 (21:04 -0700)
Cycript.l.in
Cycript.yy.in

index a599ed9f5bbba3ff7abc6ce2ba18d26c586a775c..d71411088fcea020526b3ecac2725f4e2d925e54 100644 (file)
@@ -275,6 +275,7 @@ XMLName {XMLNameStart}{XMLNamePart}*
 "in"           L C I(word, Word("in"), yyextra->in_.top() ? tk::In_ : tk::In);
 "instanceof"   L C I(word, Word("instanceof"), tk::InstanceOf);
 "new"          L C I(word, Word("new"), tk::New);
 "in"           L C I(word, Word("in"), yyextra->in_.top() ? tk::In_ : tk::In);
 "instanceof"   L C I(word, Word("instanceof"), tk::InstanceOf);
 "new"          L C I(word, Word("new"), tk::New);
+"of"           L C I(word, Word("of"), tk::Of);
 "return"       L R I(word, Word("return"), tk::Return);
 "switch"       L C I(word, Word("switch"), tk::Switch);
 "this"         L C I(this, This(), tk::This);
 "return"       L R I(word, Word("return"), tk::Return);
 "switch"       L C I(word, Word("switch"), tk::Switch);
 "this"         L C I(this, This(), tk::This);
index 241d93f00aa8dc26bd04dae10913ce64791baa85..9943a9d2459edc94bbaeaca5090d044e83241c2d 100644 (file)
@@ -250,6 +250,7 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %token <word_> In_ "!in"
 %token <word_> InstanceOf "instanceof"
 %token <word_> New "new"
 %token <word_> In_ "!in"
 %token <word_> InstanceOf "instanceof"
 %token <word_> New "new"
+%token <word_> Of "of"
 %token <word_> Return "return"
 %token <word_> Switch "switch"
 %token <this_> This "this"
 %token <word_> Return "return"
 %token <word_> Switch "switch"
 %token <this_> This "this"
@@ -597,6 +598,7 @@ Word
     /* XXX: | "instanceof" { $$ = $1; } */
     | "new" { $$ = $1; }
     | "null" { $$ = $1; }
     /* XXX: | "instanceof" { $$ = $1; } */
     | "new" { $$ = $1; }
     | "null" { $$ = $1; }
+    | "of" { $$ = $1; }
     | "return" NewLineOpt { $$ = $1; }
     | "super" { $$ = $1; }
     | "switch" { $$ = $1; }
     | "return" NewLineOpt { $$ = $1; }
     | "super" { $$ = $1; }
     | "switch" { $$ = $1; }
@@ -1124,9 +1126,10 @@ ForStatementInitialiser
     | LexSetRegExp "var" VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
     ;
 /* }}} */
     | LexSetRegExp "var" VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
     ;
 /* }}} */
-/* 12.6.4 The for-in Statement {{{ */
+/* 12.6.4 The for-in and for-of Statements {{{ */
 ForInStatement
     : "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
 ForInStatement
     : "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
+    | "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "of" Expression ")" Statement { $$ = CYNew CYForEachIn($4, $7, $9); }
     ;
 
 ForInStatementInitialiser
     ;
 
 ForInStatementInitialiser