1.1 --- a/src/Parser.cpp Sun Jul 29 19:27:26 2012 -0700
1.2 +++ b/src/Parser.cpp Sun Jul 29 19:37:47 2012 -0700
1.3 @@ -583,10 +583,10 @@
1.4
1.5 Statement *decl = NULL;
1.6 if (!match(TOK_SEMICOLON)) {
1.7 - if (scanner_.peek() == TOK_NEW) {
1.8 + if (match(TOK_NEW)) {
1.9 if (!enterScope(Scope::BLOCK))
1.10 return NULL;
1.11 - if ((decl = variableDeclaration()) == NULL)
1.12 + if ((decl = variableDeclaration(TOK_NEW)) == NULL)
1.13 return NULL;
1.14 } else {
1.15 if ((decl = expressionStatement()) == NULL)
1.16 @@ -635,11 +635,8 @@
1.17 }
1.18
1.19 VariableDeclaration *
1.20 -Parser::variableDeclaration()
1.21 +Parser::variableDeclaration(TokenKind kind)
1.22 {
1.23 - if (!expect(TOK_NEW))
1.24 - return NULL;
1.25 -
1.26 Local<String> tag(zone_);
1.27 if (matchName(tag.ref(), TOK_LABEL) && !tag)
1.28 return NULL;
1.29 @@ -679,7 +676,7 @@
1.30 return NULL;
1.31 }
1.32
1.33 - return new (pool_) VariableDeclaration(var->pos(), var, tag, postDimensions, expr);
1.34 + return new (pool_) VariableDeclaration(var->pos(), kind, var, tag, postDimensions, expr);
1.35 }
1.36
1.37 Statement *
1.38 @@ -803,9 +800,12 @@
1.39 // Statements which must be followed by a semicolon will break out of the
1.40 // switch. If they may end in BlockStatements, they'll immediately return.
1.41
1.42 - switch (scanner_.peek()) {
1.43 + TokenKind kind = scanner_.peek();
1.44 + switch (kind) {
1.45 + case TOK_CONST:
1.46 case TOK_NEW:
1.47 - if ((statement = variableDeclaration()) == NULL)
1.48 + scanner_.scan();
1.49 + if ((statement = variableDeclaration(kind)) == NULL)
1.50 return NULL;
1.51 break;
1.52
1.53 @@ -1066,7 +1066,8 @@
1.54 for (;;) {
1.55 Statement *statement = NULL;
1.56
1.57 - switch (scanner_.peek()) {
1.58 + TokenKind kind = scanner_.peek();
1.59 + switch (kind) {
1.60 case TOK_ERROR:
1.61 return NULL;
1.62
1.63 @@ -1083,7 +1084,7 @@
1.64 case TOK_NATIVE:
1.65 case TOK_STOCK:
1.66 {
1.67 - TokenKind kind = scanner_.scan();
1.68 + scanner_.scan();
1.69 if ((statement = function(kind)) == NULL)
1.70 return NULL;
1.71 if ((kind == TOK_FORWARD || kind == TOK_NATIVE) && !matchSemicolon())
1.72 @@ -1091,9 +1092,11 @@
1.73 break;
1.74 }
1.75
1.76 + case TOK_CONST:
1.77 case TOK_NEW:
1.78 {
1.79 - if ((statement = variableDeclaration()) == NULL)
1.80 + scanner_.scan();
1.81 + if ((statement = variableDeclaration(kind)) == NULL)
1.82 return NULL;
1.83 if (!matchSemicolon())
1.84 return NULL;