mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
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:
parent
350953e598
commit
321f88b1be
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user