From 8230d734952e6b4aa5eb0d047f4c449b1c037656 Mon Sep 17 00:00:00 2001 From: John Breaux Date: Wed, 23 Aug 2023 00:00:28 -0500 Subject: [PATCH] token.rs: Lex numbers of arbitrary length, for better errors --- src/tokenizer/token.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tokenizer/token.rs b/src/tokenizer/token.rs index ac0729e..232c4b6 100644 --- a/src/tokenizer/token.rs +++ b/src/tokenizer/token.rs @@ -4,6 +4,7 @@ //! A [Token] represents all valid sequences of characters, //! sorted by meaning +use crate::Error; use regex::Regex; use std::{ fmt::{Debug, Display}, @@ -56,8 +57,6 @@ impl<$t> From<&$t str> for $type { }; } -use crate::Error; - #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Token<'text> { /// The type of this token @@ -194,7 +193,7 @@ regex_impl! {<'text> Token<'text> { regex!(Type::RadixMarkerBin = r"(?i)^0b") } pub fn expect_number(text: &str) -> Option { - regex!(Type::Number = r"^+?[[:xdigit:]]{1,5}") + regex!(Type::Number = r"^+?[[:xdigit:]]+") } pub fn expect_minus(text: &str) -> Option { regex!(Type::Minus = r"^-")