From c8cec8d0b3d8f6b25d485ca3b187a85fd71191cc Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 20 Feb 2015 15:52:30 +0100 Subject: Parsing of array types and basic implementation. --- SolidityParser.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'SolidityParser.cpp') diff --git a/SolidityParser.cpp b/SolidityParser.cpp index ddb58244..6c53887a 100644 --- a/SolidityParser.cpp +++ b/SolidityParser.cpp @@ -480,6 +480,7 @@ BOOST_AUTO_TEST_CASE(statement_starting_with_type_conversion) char const* text = "contract test {\n" " function fun() {\n" " uint64(2);\n" + " uint64[7](3);\n" " }\n" "}\n"; BOOST_CHECK_NO_THROW(parseText(text)); @@ -753,6 +754,45 @@ BOOST_AUTO_TEST_CASE(external_variable) BOOST_CHECK_THROW(parseText(text), ParserError); } +BOOST_AUTO_TEST_CASE(arrays_in_storage) +{ + char const* text = R"( + contract c { + uint[10] a; + uint[] a2; + struct x { uint[2**20] b; y[0] c; } + struct y { uint d; mapping(uint=>x)[] e; } + })"; + BOOST_CHECK_NO_THROW(parseText(text)); +} + +BOOST_AUTO_TEST_CASE(arrays_in_events) +{ + char const* text = R"( + contract c { + event e(uint[10] a, string7[8] indexed b, c[3] x); + })"; + BOOST_CHECK_NO_THROW(parseText(text)); +} + +BOOST_AUTO_TEST_CASE(arrays_in_expressions) +{ + char const* text = R"( + contract c { + function f() { c[10] a = 7; uint8[10 * 2] x; } + })"; + BOOST_CHECK_NO_THROW(parseText(text)); +} + +BOOST_AUTO_TEST_CASE(multi_arrays) +{ + char const* text = R"( + contract c { + mapping(uint => mapping(uint => int8)[8][][9])[] x; + })"; + BOOST_CHECK_NO_THROW(parseText(text)); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit From 9798d700dd27f87a33e3e251e812e9d62e4c9f18 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 21 Feb 2015 18:25:08 +0100 Subject: Allow conversion to dynamic arrays and update grammar. --- SolidityParser.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'SolidityParser.cpp') diff --git a/SolidityParser.cpp b/SolidityParser.cpp index 6c53887a..b3fcd648 100644 --- a/SolidityParser.cpp +++ b/SolidityParser.cpp @@ -481,6 +481,17 @@ BOOST_AUTO_TEST_CASE(statement_starting_with_type_conversion) " function fun() {\n" " uint64(2);\n" " uint64[7](3);\n" + " uint64[](3);\n" + " }\n" + "}\n"; + BOOST_CHECK_NO_THROW(parseText(text)); +} + +BOOST_AUTO_TEST_CASE(type_conversion_to_dynamic_array) +{ + char const* text = "contract test {\n" + " function fun() {\n" + " var x = uint64[](3);\n" " }\n" "}\n"; BOOST_CHECK_NO_THROW(parseText(text)); -- cgit