Parser is now able to parse the AST module

This commit is contained in:
Hackerpilot 2013-06-27 02:07:45 -07:00
parent 94d4bf7503
commit 62734e58df
1 changed files with 26 additions and 17 deletions

View File

@ -1726,10 +1726,10 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
break; break;
case auto_: case auto_:
if (startsWith(auto_, ref_, identifier, lParen) if (startsWith(auto_, ref_, identifier, lParen)
|| startsWith(auto_, identifier, lParen)) || startsWith(auto_, identifier, lParen))
{
node.functionDeclaration = parseFunctionDeclaration(); node.functionDeclaration = parseFunctionDeclaration();
} else
node.variableDeclaration = parseVariableDeclaration();
break; break;
case ref_: case ref_:
if (startsWith(ref_, auto_, identifier, lParen) if (startsWith(ref_, auto_, identifier, lParen)
@ -1744,7 +1744,6 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
} }
break; break;
case at: case at:
case extern_:
case align_: case align_:
case deprecated_: case deprecated_:
case private_: case private_:
@ -1759,10 +1758,8 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
case abstract_: case abstract_:
case const_: case const_:
case gshared: case gshared:
case shared_:
case immutable_: case immutable_:
case inout_: case inout_:
case static_:
case pure_: case pure_:
case nothrow_: case nothrow_:
node.attributedDeclaration = parseAttributedDeclaration(); node.attributedDeclaration = parseAttributedDeclaration();
@ -2129,16 +2126,29 @@ class ClassFour(A, B) if (someTest()) : Super {}}c;
auto node = new ForeachStatement; auto node = new ForeachStatement;
if (currentIs(TokenType.foreach_)) if (currentIs(TokenType.foreach_))
{ advance();
expect(TokenType.foreach_);
}
else else
{ if (expect(TokenType.foreach_reverse_) is null) return null;
expect(TokenType.foreach_reverse_); if (expect(TokenType.lParen) is null) return null;
} auto feType = parseForeachTypeList();
expect(TokenType.lParen); bool canBeRange = feType.items.length == 0;
expect(TokenType.rParen); expect(TokenType.semicolon);
node.low = parseExpression();
if (node.low is null) return null;
if (currentIs(TokenType.slice))
{
if (!canBeRange)
{
error(`Cannot have more than one foreach varible for a foreach range statement`);
return null;
}
advance();
node.high = parseExpression();
if (node.high is null) return null;
}
if (expect(TokenType.rParen) is null) return null;
node.statementNoCaseNoDefault = parseStatementNoCaseNoDefault(); node.statementNoCaseNoDefault = parseStatementNoCaseNoDefault();
if (node.statementNoCaseNoDefault is null) return null;
return node; return node;
} }
@ -3350,9 +3360,8 @@ invariant() foo();
break; break;
case foreach_: case foreach_:
case foreach_reverse_: case foreach_reverse_:
// TODO node.foreachStatement = parseForeachStatement();
advance(); break;
return null;
case switch_: case switch_:
node.switchStatement = parseSwitchStatement(); node.switchStatement = parseSwitchStatement();
break; break;