From d2544d0655a7d7851b3142cd5452e6f88f006a7d Mon Sep 17 00:00:00 2001 From: Jonas Maier Date: Sun, 31 May 2026 19:51:06 +0200 Subject: add . to regex parsing --- src/parse/mod.rs | 6 ++++-- src/parse/regex/mod.rs | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/parse') diff --git a/src/parse/mod.rs b/src/parse/mod.rs index b475943..4cba0fd 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -1875,8 +1875,10 @@ pub struct Case { } impl CmdDisplay for CaseBranch { - fn cdisplay(&self, _w: &mut dyn std::io::Write) -> std::io::Result<()> { - todo!() + fn cdisplay(&self, w: &mut dyn std::io::Write) -> std::io::Result<()> { + write!(w, "case_branch(\"{:?}\", ", self.pattern)?; + self.block.cdisplay(w)?; + write!(w, ")") } } diff --git a/src/parse/regex/mod.rs b/src/parse/regex/mod.rs index 1c761a1..d5e4cdf 100644 --- a/src/parse/regex/mod.rs +++ b/src/parse/regex/mod.rs @@ -89,7 +89,7 @@ fn parse_rep(s: &mut super::Cursor<'_>) -> Result { // TODO: non-greedy } -const SYMBOLS: &[u8] = b"{}[]()*+-?| "; +const SYMBOLS: &[u8] = b"{}[]()*+-?|. "; fn is_symbol(x: u8) -> bool { SYMBOLS.contains(&x) } @@ -150,6 +150,10 @@ fn parse_atom(s: &mut super::Cursor<'_>) -> Result { } Ok(inner) } + b'.' => { + s.adv(); + Ok(Pattern::Range(0, 127)) + } x if is_symbol(x) => Ok(Pattern::Nothing), ch => { s.adv(); -- cgit v1.2.3