From 12d6a22c7dcdc0cb6e169b082b4553caec0e6027 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 23 Dec 2019 22:48:51 +0000 Subject: Update dhall-lang submodule --- dhall/src/syntax/text/parser.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'dhall/src') 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 { - 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 { - 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)] -- cgit v1.2.3