Allow splitting string literals into multiple parts

This commit is contained in:
Gaith Hallak
2019-11-26 14:41:30 +03:00
parent 200a92b40e
commit 4a1e85436b
15 changed files with 76 additions and 6 deletions
+1 -1
View File
@@ -505,7 +505,7 @@ BOOST_AUTO_TEST_CASE(valid_hex_literal)
{
Scanner scanner(CharStream("{ hex\"00112233FF\"", ""));
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace);
BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral);
BOOST_CHECK_EQUAL(scanner.next(), Token::HexStringLiteral);
BOOST_CHECK_EQUAL(scanner.currentLiteral(), std::string("\x00\x11\x22\x33\xFF", 5));
}
@@ -0,0 +1,8 @@
contract test {
function f() public pure returns (bytes32) {
bytes32 escapeCharacters = hex"aa" hex"b";
return escapeCharacters;
}
}
// ----
// ParserError: (108-112): Expected even number of hex-nibbles within double-quotes.
@@ -0,0 +1,9 @@
contract test {
function f() public pure returns (bytes32) {
bytes32 escapeCharacters = hex"0000"
hex"deaf"
hex"feed";
return escapeCharacters;
}
}
// ----
@@ -0,0 +1,10 @@
contract test {
function f() public pure returns (bytes32) {
bytes32 escapeCharacters = hex"0000"
"deaf"
"feed";
return escapeCharacters;
}
}
// ----
// ParserError: (118-124): Expected ';' but got 'StringLiteral'
@@ -0,0 +1,8 @@
contract test {
function f() public pure returns (bytes32) {
bytes32 escapeCharacters = hex"aa" hex"bb" "cc";
return escapeCharacters;
}
}
// ----
// ParserError: (116-120): Expected ';' but got 'StringLiteral'
@@ -0,0 +1,8 @@
contract test {
function f() public pure returns (bytes32) {
bytes32 escapeCharacters = "foo" "bar" hex"aa";
return escapeCharacters;
}
}
// ----
// ParserError: (112-119): Expected ';' but got 'HexStringLiteral'
@@ -0,0 +1,7 @@
contract test {
function f() public pure returns (bytes32) {
bytes32 escapeCharacters = "first" "second" "third";
return escapeCharacters;
}
}
// ----