Allow usage of C++11 auto keyword.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 13 Jun 2012 00:17:42 +0000 (17:17 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 13 Jun 2012 00:17:42 +0000 (17:17 -0700)
Cycript.l.in
Cycript.yy.in

index 1923a34b88f7269a57329cbe5fb75fffa8c9172c..f311c69d4725664eb36beff6b44d62e683d385a3 100644 (file)
@@ -258,6 +258,7 @@ XMLName {XMLNameStart}{XMLNamePart}*
 "null"         L C I(null, Null(), tk::Null);
 "true"         L C I(true, True(), tk::True);
 
+"auto"         L C I(word, Word("auto"), tk::Auto);
 "break"        L R I(word, Word("break"), tk::Break);
 "case"         L C I(word, Word("case"), tk::Case);
 "catch"        L C I(word, Word("catch"), tk::Catch);
index cd63aecd68db6b281609451b3158b3395725e217..aa5f535c616bd268aaeb43a2a156c102f6a98474 100644 (file)
@@ -234,6 +234,7 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %token <true_> True "true"
 
 // ES3/ES5/WIE/JSC Reserved
+%token <word_> Auto "auto"
 %token <word_> Break "break"
 %token <word_> Case "case"
 %token <word_> Catch "catch"
@@ -551,6 +552,10 @@ BRACE
     : "{"
     | "\n{"
     ;
+
+Var_
+    : "var"
+    ;
 /* }}} */
 
 /* 7.6 Identifier Names and Identifiers {{{ */
@@ -565,6 +570,7 @@ NewLineOpt
 
 Word
     : Identifier { $$ = $1; }
+    | "auto" { $$ = $1; }
     | "break" NewLineOpt { $$ = $1; }
     | "case" { $$ = $1; }
     | "catch" { $$ = $1; }
@@ -1080,7 +1086,7 @@ LetOrConst
 /* }}} */
 /* 12.2.2 Variable Statement {{{ */
 VariableStatement
-    : "var" VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
+    : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
     ;
 
 VariableDeclarationList_
@@ -1156,7 +1162,7 @@ IterationStatement
 
 ForStatementInitialiser
     : ExpressionOpt { $$ = $1; }
-    | LexSetRegExp "var" VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
+    | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
     ;
 /* }}} */
 /* 12.6.4 The for-in and for-of Statements {{{ */
@@ -1167,7 +1173,7 @@ IterationStatement
 
 ForInStatementInitialiser
     : LeftHandSideExpression { $$ = $1; }
-    | LexSetRegExp "var" VariableDeclaration { $$ = $3; }
+    | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
     ;
 /* }}} */
 
@@ -1521,6 +1527,11 @@ MemberAccess
     | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
     ;
 /* }}} */
+/* Cycript (C): auto Compatibility {{{ */
+Var_
+    : "auto"
+    ;
+/* }}} */
 @end
 
 /* YUI: Documentation Comments {{{ */