mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-16 12:10:15 +00:00
Support Parsing of hexadecimal literals that start with 0x (#324)
* Add support for 0x prefixed bin literal * Add tests * Fix formatting for test
This commit is contained in:
parent
a95c81fb13
commit
70ffa4166c
2 changed files with 16 additions and 0 deletions
|
@ -417,6 +417,17 @@ impl<'a> Tokenizer<'a> {
|
|||
// numbers and period
|
||||
'0'..='9' | '.' => {
|
||||
let mut s = peeking_take_while(chars, |ch| matches!(ch, '0'..='9'));
|
||||
|
||||
// match binary literal that starts with 0x
|
||||
if s == "0" && chars.peek() == Some(&'x') {
|
||||
chars.next();
|
||||
let s2 = peeking_take_while(
|
||||
chars,
|
||||
|ch| matches!(ch, '0'..='9' | 'A'..='F' | 'a'..='f'),
|
||||
);
|
||||
return Ok(Some(Token::HexStringLiteral(s2)));
|
||||
}
|
||||
|
||||
// match one period
|
||||
if let Some('.') = chars.peek() {
|
||||
s.push('.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue