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 | |
parent | c7a8a3879e04bc027881653e629822f989d45876 (diff) |
Update dhall-lang submodule
m--------- | dhall-lang | 0 | ||||
-rw-r--r-- | dhall/src/syntax/text/parser.rs | 28 |
2 files changed, 18 insertions, 10 deletions
diff --git a/dhall-lang b/dhall-lang -Subproject 9f248138f69ee5e22192dc3d0417d5c77b189e0 +Subproject c7dd51ec433e07433243cf1a1134655dbab6cc9 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)] |