From 0d56ef32c43d7df2033a687afae4c5b2b13e68c1 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 6 Jun 2012 21:04:20 -0700 Subject: [PATCH] Add support for ECMA6 for-of iteration statements. --- Cycript.l.in | 1 + Cycript.yy.in | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cycript.l.in b/Cycript.l.in index a599ed9..d714110 100644 --- a/Cycript.l.in +++ b/Cycript.l.in @@ -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); +"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); diff --git a/Cycript.yy.in b/Cycript.yy.in index 241d93f..9943a9d 100644 --- a/Cycript.yy.in +++ b/Cycript.yy.in @@ -250,6 +250,7 @@ int cylex(YYSTYPE *, cy::location *, void *); %token In_ "!in" %token InstanceOf "instanceof" %token New "new" +%token Of "of" %token Return "return" %token Switch "switch" %token This "this" @@ -597,6 +598,7 @@ Word /* XXX: | "instanceof" { $$ = $1; } */ | "new" { $$ = $1; } | "null" { $$ = $1; } + | "of" { $$ = $1; } | "return" NewLineOpt { $$ = $1; } | "super" { $$ = $1; } | "switch" { $$ = $1; } @@ -1124,9 +1126,10 @@ ForStatementInitialiser | 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); } + | "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "of" Expression ")" Statement { $$ = CYNew CYForEachIn($4, $7, $9); } ; ForInStatementInitialiser -- 2.45.2