Add octal binary literals (#5604)

Schema `0o[77]` with the same padding behavior as the other binary literals

- this updates #5551
- test for parsing binary from octal
- test for string parsing
This commit is contained in:
Jason Toffaletti
2022-05-23 02:01:15 -07:00
committed by GitHub
parent 0e1bfae13d
commit 98a4280c41
2 changed files with 90 additions and 1 deletions

View File

@ -1094,7 +1094,11 @@ pub fn parse_binary(
) -> (Expression, Option<ParseError>) {
let (hex_value, err) = parse_binary_with_base(working_set, span, 16, 2, b"0x[", b"]");
if err.is_some() {
return parse_binary_with_base(working_set, span, 2, 8, b"0b[", b"]");
let (octal_value, err) = parse_binary_with_base(working_set, span, 8, 3, b"0o[", b"]");
if err.is_some() {
return parse_binary_with_base(working_set, span, 2, 8, b"0b[", b"]");
}
return (octal_value, err);
}
(hex_value, err)
}