mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Corrected indentation.
This commit is contained in:
parent
0a1ebe4f51
commit
c3faa433ef
4
AST.h
4
AST.h
@ -200,8 +200,8 @@ public:
|
|||||||
class Block : public Statement
|
class Block : public Statement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Block(Location const& _location)
|
explicit Block(Location const& _location, vecptr<Statement> const& _statements)
|
||||||
: Statement(_location)
|
: Statement(_location), m_statements(_statements)
|
||||||
{}
|
{}
|
||||||
private:
|
private:
|
||||||
vecptr<Statement> m_statements;
|
vecptr<Statement> m_statements;
|
||||||
|
22
Parser.cpp
22
Parser.cpp
@ -231,15 +231,33 @@ ptr<ParameterList> Parser::parseParameterList()
|
|||||||
|
|
||||||
ptr<Block> Parser::parseBlock()
|
ptr<Block> Parser::parseBlock()
|
||||||
{
|
{
|
||||||
|
|
||||||
ASTNodeFactory nodeFactory(*this);
|
ASTNodeFactory nodeFactory(*this);
|
||||||
expectToken(Token::LBRACE);
|
expectToken(Token::LBRACE);
|
||||||
|
vecptr<Statement> statements;
|
||||||
while (m_scanner->getCurrentToken() != Token::RBRACE) {
|
while (m_scanner->getCurrentToken() != Token::RBRACE) {
|
||||||
m_scanner->next();
|
m_scanner->next();
|
||||||
// @todo
|
statements.push_back(parseStatement());
|
||||||
}
|
}
|
||||||
nodeFactory.markEndPosition();
|
nodeFactory.markEndPosition();
|
||||||
expectToken(Token::RBRACE);
|
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)
|
void Parser::expectToken(Token::Value _value)
|
||||||
|
1
Parser.h
1
Parser.h
@ -52,6 +52,7 @@ private:
|
|||||||
ptr<Mapping> parseMapping();
|
ptr<Mapping> parseMapping();
|
||||||
ptr<ParameterList> parseParameterList();
|
ptr<ParameterList> parseParameterList();
|
||||||
ptr<Block> parseBlock();
|
ptr<Block> parseBlock();
|
||||||
|
ptr<Statement> parseStatement();
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// Helper functions
|
/// Helper functions
|
||||||
|
4
Token.h
4
Token.h
@ -236,7 +236,7 @@ namespace solidity {
|
|||||||
|
|
||||||
|
|
||||||
class Token {
|
class Token {
|
||||||
public:
|
public:
|
||||||
// All token values.
|
// All token values.
|
||||||
#define T(name, string, precedence) name,
|
#define T(name, string, precedence) name,
|
||||||
enum Value {
|
enum Value {
|
||||||
@ -363,7 +363,7 @@ class Token {
|
|||||||
return m_precedence[tok];
|
return m_precedence[tok];
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char* const m_name[NUM_TOKENS];
|
static const char* const m_name[NUM_TOKENS];
|
||||||
static const char* const m_string[NUM_TOKENS];
|
static const char* const m_string[NUM_TOKENS];
|
||||||
static const int8_t m_precedence[NUM_TOKENS];
|
static const int8_t m_precedence[NUM_TOKENS];
|
||||||
|
Loading…
Reference in New Issue
Block a user