Adding a ForStatement solidity AST Node.

- Adding ForStatement node
- Implemented Parsing for ForStatement
- A simple parsing test for the ForStatement
- Work in progress
This commit is contained in:
Lefteris Karapetsas 2014-12-15 17:45:18 +01:00
parent 350953e598
commit 321f88b1be

View File

@ -49,6 +49,23 @@ ASTPointer<ContractDefinition> parseText(std::string const& _source)
BOOST_FAIL("No contract found in source.");
return ASTPointer<ContractDefinition>();
}
ASTPointer<ContractDefinition> parseTextExplainError(std::string const& _source)
{
try
{
return parseText(_source);
}
catch (Exception const& exception)
{
// LTODO: Print the error in a kind of a better way?
// In absence of CompilerStack we can't use SourceReferenceFormatter
cout << "Exception while parsing: " << diagnostic_information(exception);
// rethrow to signal test failure
throw exception;
}
}
}
@ -357,6 +374,17 @@ BOOST_AUTO_TEST_CASE(while_loop)
BOOST_CHECK_NO_THROW(parseText(text));
}
BOOST_AUTO_TEST_CASE(for_loop)
{
char const* text = "contract test {\n"
" function fun(uint256 a) {\n"
" for (uint256 i = 0; i < 10; i++;)\n"
" { uint256 x = i; break; continue; }\n"
" }\n"
"}\n";
BOOST_CHECK_NO_THROW(parseTextExplainError(text));
}
BOOST_AUTO_TEST_CASE(if_statement)
{
char const* text = "contract test {\n"