|
|
@ -231,15 +231,33 @@ ptr<ParameterList> Parser::parseParameterList() |
|
|
|
|
|
|
|
ptr<Block> Parser::parseBlock() |
|
|
|
{ |
|
|
|
|
|
|
|
ASTNodeFactory nodeFactory(*this); |
|
|
|
expectToken(Token::LBRACE); |
|
|
|
vecptr<Statement> statements; |
|
|
|
while (m_scanner->getCurrentToken() != Token::RBRACE) { |
|
|
|
m_scanner->next(); |
|
|
|
// @todo
|
|
|
|
statements.push_back(parseStatement()); |
|
|
|
} |
|
|
|
nodeFactory.markEndPosition(); |
|
|
|
expectToken(Token::RBRACE); |
|
|
|
return nodeFactory.createNode<Block>(); |
|
|
|
return nodeFactory.createNode<Block>(statements); |
|
|
|
} |
|
|
|
|
|
|
|
ptr<Statement> Parser::parseStatement() |
|
|
|
{ |
|
|
|
|
|
|
|
switch (m_scanner->getCurrentToken()) { |
|
|
|
case Token::IF: |
|
|
|
return parseIfStatement(); |
|
|
|
case Token::WHILE: |
|
|
|
return parseWhileStatement(); |
|
|
|
case Token::LBRACE: |
|
|
|
return parseBlock(); |
|
|
|
// starting from here, all statements must be terminated by a semicolon
|
|
|
|
case Token::CONTINUE: // all following
|
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void Parser::expectToken(Token::Value _value) |
|
|
|