diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-03-21 00:50:26 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-03-25 21:26:05 +0800 |
commit | 9d6d7ccab86da43da03b79f7b74bf7146c0c0b14 (patch) | |
tree | 63ac5a52c0064df5a9a87644a8638beb7f3424c2 /Parser.cpp | |
parent | 8f8e407306172ab75f5b200c1f1df87bb55fa2a6 (diff) | |
download | dexon-solidity-9d6d7ccab86da43da03b79f7b74bf7146c0c0b14.tar.gz dexon-solidity-9d6d7ccab86da43da03b79f7b74bf7146c0c0b14.tar.zst dexon-solidity-9d6d7ccab86da43da03b79f7b74bf7146c0c0b14.zip |
Parsing of not fully implemented functions
- Adding the possibility of omitting a function body by simply ending a
function definition with a semicolon
- Such a function is marked as not fully implemented and any contract
that contains such a function is considered a not fully implemented contract
Diffstat (limited to 'Parser.cpp')
-rw-r--r-- | Parser.cpp | 33 |
1 files changed, 28 insertions, 5 deletions
@@ -116,6 +116,7 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition() { ASTNodeFactory nodeFactory(*this); ASTPointer<ASTString> docString; + bool contractFullyImplemented = true; if (m_scanner->getCurrentCommentLiteral() != "") docString = make_shared<ASTString>(m_scanner->getCurrentCommentLiteral()); expectToken(Token::Contract); @@ -141,7 +142,12 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition() if (currentToken == Token::RBrace) break; else if (currentToken == Token::Function) - functions.push_back(parseFunctionDefinition(name.get())); + { + ASTPointer<FunctionDefinition> func = parseFunctionDefinition(name.get()); + functions.push_back(func); + if (!func->isFullyImplemented()) + contractFullyImplemented = false; + } else if (currentToken == Token::Struct) structs.push_back(parseStructDefinition()); else if (currentToken == Token::Enum) @@ -164,8 +170,18 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition() } nodeFactory.markEndPosition(); expectToken(Token::RBrace); - return nodeFactory.createNode<ContractDefinition>(name, docString, baseContracts, structs, enums, - stateVariables, functions, modifiers, events); + return nodeFactory.createNode<ContractDefinition>( + name, + docString, + baseContracts, + structs, + enums, + stateVariables, + functions, + modifiers, + events, + contractFullyImplemented + ); } ASTPointer<InheritanceSpecifier> Parser::parseInheritanceSpecifier() @@ -247,8 +263,15 @@ ASTPointer<FunctionDefinition> Parser::parseFunctionDefinition(ASTString const* } else returnParameters = createEmptyParameterList(); - ASTPointer<Block> block = parseBlock(); - nodeFactory.setEndPositionFromNode(block); + ASTPointer<Block> block = ASTPointer<Block>(); + nodeFactory.markEndPosition(); + if (m_scanner->getCurrentToken() != Token::Semicolon) + { + block = parseBlock(); + nodeFactory.setEndPositionFromNode(block); + } + else + m_scanner->next(); // just consume the ';' bool const c_isConstructor = (_contractName && *name == *_contractName); return nodeFactory.createNode<FunctionDefinition>(name, visibility, c_isConstructor, docstring, parameters, isDeclaredConst, modifiers, |