aboutsummaryrefslogtreecommitdiff
path: root/src/regex.rs
diff options
context:
space:
mode:
authoromagdy7 <omar.professional8777@gmail.com>2023-12-10 20:50:35 +0200
committeromagdy7 <omar.professional8777@gmail.com>2023-12-10 20:50:35 +0200
commit180572c70477e78c43c745d2331ebf4d39d9ff10 (patch)
treebf09fc9d4df1d5d638e339b56a69d583d2c7ee16 /src/regex.rs
parent2419f52d434096edebab85b3fa7141bcfa584583 (diff)
downloadrex-master.tar.xz
rex-master.zip
Fixed a bug where it wouldn't match spacesHEADmaster
Diffstat (limited to 'src/regex.rs')
-rw-r--r--src/regex.rs12
1 files changed, 11 insertions, 1 deletions
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<std::str::Chars>,
) -> 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::<String>());
+ 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,
}
}