mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Expose hex literal to the Yul parser
This allows nicer error messages.
This commit is contained in:
@@ -652,9 +652,8 @@ BOOST_AUTO_TEST_CASE(hex_prefix_only)
|
||||
BOOST_CHECK_EQUAL(scanner.currentError(), ScannerError::IllegalToken);
|
||||
scanner.reset(CharStream("{ hex", ""));
|
||||
scanner.setScannerMode(ScannerKind::Yul);
|
||||
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier);
|
||||
BOOST_CHECK_EQUAL(scanner.currentLiteral(), "hex");
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal);
|
||||
BOOST_CHECK_EQUAL(scanner.currentError(), ScannerError::IllegalToken);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(hex_invalid_space)
|
||||
@@ -674,10 +673,8 @@ BOOST_AUTO_TEST_CASE(hex_invalid_token)
|
||||
scanner.reset(CharStream("{ hex test", ""));
|
||||
scanner.setScannerMode(ScannerKind::Yul);
|
||||
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier);
|
||||
BOOST_CHECK_EQUAL(scanner.currentLiteral(), "hex");
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Identifier);
|
||||
BOOST_CHECK_EQUAL(scanner.currentLiteral(), "test");
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal);
|
||||
BOOST_CHECK_EQUAL(scanner.currentError(), ScannerError::IllegalToken);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(valid_hex_literal)
|
||||
|
||||
@@ -6,4 +6,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError 6913: (86-87): Call or assignment expected.
|
||||
// ParserError 3772: (72-81): Hex literals are not valid in this context.
|
||||
|
||||
@@ -6,4 +6,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (70-76): Expected ',' but got 'StringLiteral'
|
||||
// ParserError 3772: (67-76): Hex literals are not valid in this context.
|
||||
|
||||
@@ -8,4 +8,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError 4805: (95-99): Literal expected.
|
||||
// ParserError 3772: (92-99): Hex literals are not valid in this context.
|
||||
|
||||
@@ -21,7 +21,7 @@ contract C {
|
||||
let fallback := 1
|
||||
// for is a Yul keyword
|
||||
// function is a Yul keyword
|
||||
let hex := 1
|
||||
// hex is a Yul keyword
|
||||
// if is a Yul keyword
|
||||
let indexed := 1
|
||||
let interface := 1
|
||||
@@ -110,4 +110,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 5740: (944-2157): Unreachable code.
|
||||
// Warning 5740: (955-2168): Unreachable code.
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
let x := hex"0011"
|
||||
}
|
||||
// ----
|
||||
// ParserError 6913: (25-26): Call or assignment expected.
|
||||
// ParserError 3772: (15-24): Hex literals are not valid in this context.
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
pop(hex"2233")
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (13-19): Expected ',' but got 'StringLiteral'
|
||||
// ParserError 3772: (10-19): Hex literals are not valid in this context.
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
case hex"1122" {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 4805: (36-40): Literal expected.
|
||||
// ParserError 3772: (33-40): Hex literals are not valid in this context.
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
let fallback := 1
|
||||
// for is a Yul keyword
|
||||
// function is a Yul keyword
|
||||
let hex := 1
|
||||
// hex is a Yul keyword
|
||||
// if is a Yul keyword
|
||||
let indexed := 1
|
||||
let interface := 1
|
||||
|
||||
Reference in New Issue
Block a user