Skip to content

Commit

Permalink
Rename complete to partial consume
Browse files Browse the repository at this point in the history
This is more descriptive.

Signed-off-by: Sean Young <sean@mess.org>
  • Loading branch information
seanyoung committed Aug 16, 2024
1 parent 0813977 commit 119f6fe
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
4 changes: 2 additions & 2 deletions irp/src/build_dfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ impl<'a> Builder<'a> {
if flash {
Action::Flash {
length: length.clone(),
complete: true,
partial_consume: true,
}
} else {
Action::Gap {
length: length.clone(),
complete: true,
partial_consume: true,
}
},
);
Expand Down
18 changes: 9 additions & 9 deletions irp/src/build_nfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ pub(crate) enum Length {
pub(crate) enum Action {
Flash {
length: Length,
complete: bool,
partial_consume: bool,
},
Gap {
length: Length,
complete: bool,
partial_consume: bool,
},
Set {
var: String,
Expand Down Expand Up @@ -109,12 +109,12 @@ impl NFA {
let actions = vec![if flash {
Action::Flash {
length: Length::Expression(length),
complete: true,
partial_consume: true,
}
} else {
Action::Gap {
length: Length::Expression(length),
complete: true,
partial_consume: true,
}
}];

Expand Down Expand Up @@ -1153,7 +1153,7 @@ impl<'a> Builder<'a> {
dest: node,
actions: vec![Action::Flash {
length: Length::Expression(Rc::new(Expression::Number(len))),
complete: last,
partial_consume: last,
}],
});

Expand All @@ -1172,7 +1172,7 @@ impl<'a> Builder<'a> {
dest: node,
actions: vec![Action::Gap {
length: Length::Expression(Rc::new(Expression::Number(len))),
complete: last,
partial_consume: last,
}],
});

Expand Down Expand Up @@ -1202,7 +1202,7 @@ impl<'a> Builder<'a> {
dest: node,
actions: vec![Action::Flash {
length: Length::Expression(expr),
complete: last,
partial_consume: last,
}],
});

Expand Down Expand Up @@ -1241,7 +1241,7 @@ impl<'a> Builder<'a> {
dest: node,
actions: vec![Action::Gap {
length: Length::Expression(expr),
complete: last,
partial_consume: last,
}],
});

Expand Down Expand Up @@ -1274,7 +1274,7 @@ impl<'a> Builder<'a> {
length: Length::Expression(Rc::new(Expression::Identifier(
"$extent".into(),
))),
complete: last,
partial_consume: last,
}],
});

Expand Down
8 changes: 4 additions & 4 deletions irp/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl<'a> Decoder<'a> {
match a {
Action::Flash {
length: Length::Expression(expected),
complete,
partial_consume: complete,
} => {
let expected = expected.eval(vartab).unwrap();

Expand All @@ -372,7 +372,7 @@ impl<'a> Decoder<'a> {
}
Action::Flash {
length: Length::Range(min, max),
complete,
partial_consume: complete,
} => {
if ir.is_none() {
return ActionResult::Retry(vartable);
Expand All @@ -389,7 +389,7 @@ impl<'a> Decoder<'a> {
}
Action::Gap {
length: Length::Expression(expected),
complete,
partial_consume: complete,
} => {
let expected = expected.eval(vartab).unwrap();

Expand All @@ -403,7 +403,7 @@ impl<'a> Decoder<'a> {
}
Action::Gap {
length: Length::Range(min, max),
complete,
partial_consume: complete,
} => {
if ir.is_none() {
return ActionResult::Retry(vartable);
Expand Down
28 changes: 24 additions & 4 deletions irp/src/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,31 @@ fn actions(actions: &[Action]) -> Vec<String> {
actions
.iter()
.map(|a| match a {
Action::Flash { length, complete } => {
format!("flash {length} {}", if *complete { "complete" } else { "" })
Action::Flash {
length,
partial_consume,
} => {
format!(
"flash {length} {}",
if *partial_consume {
"partial_consume"
} else {
""
}
)
}
Action::Gap { length, complete } => {
format!("gap {length} {}", if *complete { "complete" } else { "" })
Action::Gap {
length,
partial_consume,
} => {
format!(
"gap {length} {}",
if *partial_consume {
"partial_consume"
} else {
""
}
)
}
Action::Set { var, expr } => format!("{var} = {expr}"),
Action::AssertEq { left, right } => format!("assert {left} = {right}",),
Expand Down

0 comments on commit 119f6fe

Please sign in to comment.