Skip to content

Commit

Permalink
Paths always have lengths
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Young <[email protected]>
  • Loading branch information
seanyoung committed Apr 1, 2024
1 parent e5fb5db commit 6fd2aa0
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions irp/src/build_dfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct Path {
struct DfaEdge {
from: usize,
flash: bool,
length: Option<Rc<Expression>>,
length: Rc<Expression>,
}

impl NFA {
Expand Down Expand Up @@ -143,7 +143,7 @@ impl<'a> Builder<'a> {
self.verts[from].edges.push(Edge { dest: to, actions });
}

fn path_length(&self, path: &[Path]) -> Option<Rc<Expression>> {
fn path_length(&self, path: &[Path]) -> Rc<Expression> {
let mut len: Option<Rc<Expression>> = None;

let mut vars: HashMap<&str, Rc<Expression>> = HashMap::new();
Expand Down Expand Up @@ -181,30 +181,23 @@ impl<'a> Builder<'a> {
}
}

len
len.unwrap()
}

fn path_actions(
&self,
path: &[Path],
flash: bool,
length: Option<Rc<Expression>>,
) -> Vec<Action> {
fn path_actions(&self, path: &[Path], flash: bool, length: Rc<Expression>) -> Vec<Action> {
let mut res: Vec<Action> = Vec::new();

if let Some(length) = length {
res.push(if flash {
Action::Flash {
length,
complete: true,
}
} else {
Action::Gap {
length,
complete: true,
}
});
}
res.push(if flash {
Action::Flash {
length,
complete: true,
}
} else {
Action::Gap {
length,
complete: true,
}
});

for elem in path {
res.extend(self.nfa.verts[elem.to].entry.iter().cloned());
Expand Down

0 comments on commit 6fd2aa0

Please sign in to comment.