From 180572c70477e78c43c745d2331ebf4d39d9ff10 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Sun, 10 Dec 2023 20:50:35 +0200 Subject: Fixed a bug where it wouldn't match spaces --- src/regex.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/regex.rs') diff --git a/src/regex.rs b/src/regex.rs index 6d05a54..6f1472e 100644 --- a/src/regex.rs +++ b/src/regex.rs @@ -64,6 +64,7 @@ impl Regex { chars: &mut std::iter::Peekable, ) -> Regex { while let Some(&next) = chars.peek() { + dbg!(next); match next { '|' => { chars.next(); // Consume '|' @@ -87,6 +88,7 @@ impl Regex { )); } _ => { + // it must be a char let right = Self::parse_token(chars); if let Regex::None = right { // do nothing @@ -106,8 +108,16 @@ impl Regex { chars.next(); // Skip ')' token } + Some('$') => { + let token = Self::parse(&chars.into_iter().collect::()); + chars.next(); // Skip '$' + token + } Some('.') => Regex::Dot, - Some(c) if c.is_ascii_alphanumeric() => Sym!(c), + Some(' ') => Sym!(' '), + Some(c) if c.is_ascii_alphanumeric() => { + Sym!(c) + } _ => Regex::None, } } -- cgit v1.2.3