diff options
author | Nadrieril | 2019-12-23 22:48:51 +0000 |
---|---|---|
committer | Nadrieril | 2019-12-23 22:48:51 +0000 |
commit | 12d6a22c7dcdc0cb6e169b082b4553caec0e6027 (patch) | |
tree | 267d2ccc4122a771f0d4a995fa3b6adb53354f0c /dhall/src/syntax | |
parent | c7a8a3879e04bc027881653e629822f989d45876 (diff) |
Update dhall-lang submodule
Diffstat (limited to 'dhall/src/syntax')
-rw-r--r-- | dhall/src/syntax/text/parser.rs | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs index 27e0382..0e3e97a 100644 --- a/dhall/src/syntax/text/parser.rs +++ b/dhall/src/syntax/text/parser.rs @@ -383,19 +383,27 @@ impl DhallParser { } fn natural_literal(input: ParseInput) -> ParseResult<Natural> { - input - .as_str() - .trim() - .parse() - .map_err(|e| input.error(format!("{}", e))) + let s = input.as_str().trim(); + if s.starts_with("0x") { + let without_prefix = s.trim_start_matches("0x"); + usize::from_str_radix(without_prefix, 16) + .map_err(|e| input.error(format!("{}", e))) + } else { + s.parse().map_err(|e| input.error(format!("{}", e))) + } } fn integer_literal(input: ParseInput) -> ParseResult<Integer> { - input - .as_str() - .trim() - .parse() - .map_err(|e| input.error(format!("{}", e))) + let s = input.as_str().trim(); + let (sign, rest) = (&s[0..1], &s[1..]); + if rest.starts_with("0x") { + let without_prefix = + sign.to_owned() + rest.trim_start_matches("0x"); + isize::from_str_radix(&without_prefix, 16) + .map_err(|e| input.error(format!("{}", e))) + } else { + s.parse().map_err(|e| input.error(format!("{}", e))) + } } #[alias(expression, shortcut = true)] |