aboutsummaryrefslogtreecommitdiffstats
path: root/src/parse/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse/mod.rs')
-rw-r--r--src/parse/mod.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index 68a5e56..5815730 100644
--- a/src/parse/mod.rs
+++ b/src/parse/mod.rs
@@ -7,6 +7,8 @@ mod test;
mod span;
+pub mod regex;
+
pub trait Stage: PartialEq {
type Str: std::fmt::Debug + Clone + PartialEq;
}
@@ -1844,7 +1846,7 @@ impl Parse for Pipes<PreExpansion> {
#[derive(Debug, Clone, PartialEq)]
pub struct CaseBranch {
- pub pattern: BString,
+ pub pattern: regex::Pattern,
pub block: Block,
}
@@ -1855,10 +1857,8 @@ pub struct Case<T: Stage> {
}
impl CmdDisplay for CaseBranch {
- fn cdisplay(&self, w: &mut dyn std::io::Write) -> std::io::Result<()> {
- write!(w, "cbranch(b\"{}\", ", self.pattern.escape_ascii())?;
- self.block.cdisplay(w)?;
- write!(w, ")")
+ fn cdisplay(&self, _w: &mut dyn std::io::Write) -> std::io::Result<()> {
+ todo!()
}
}
@@ -1875,14 +1875,7 @@ impl Parse for CaseBranch {
fn parse(b: &mut Cursor<'_>) -> Result<Self> {
b.spaces();
- let mut pattern = Vec::new();
- while b.has() && b.peek() != b'{' {
- pattern.push(b.adv());
- }
- while let Some(b' ' | b'\n' | b'\t' | b'\r') = pattern.last() {
- pattern.pop();
- }
-
+ let pattern = regex::Pattern::parse(b)?;
let block = Block::parse(b)?;
Ok(Self { pattern, block })