peepmatic: Simplify linear IR
This commit splits "increments" in two; they previously contained both the
linearized left- and right-hand sides. But only the first increment ever had any
actions, so it was confusing (and space wasting) that all increments had an
"actions" vector. No more!
This commit separates the linearized left-hand side ("matches") from the
linearized right-hand side ("actions").
This commit is contained in:
@@ -19,16 +19,23 @@ where
|
||||
|
||||
for opt in &opts.optimizations {
|
||||
let mut insertion = builder.insert();
|
||||
for inc in &opt.increments {
|
||||
// Ensure that this state's associated data is this increment's
|
||||
// match operation.
|
||||
let mut is_first = true;
|
||||
for m in &opt.matches {
|
||||
// Ensure that this state's associated data is this match's
|
||||
// operation.
|
||||
if let Some(op) = insertion.get_state_data() {
|
||||
assert_eq!(*op, inc.operation);
|
||||
assert_eq!(*op, m.operation);
|
||||
} else {
|
||||
insertion.set_state_data(inc.operation);
|
||||
insertion.set_state_data(m.operation);
|
||||
}
|
||||
|
||||
insertion.next(inc.expected, inc.actions.clone().into_boxed_slice());
|
||||
let actions = if is_first {
|
||||
is_first = false;
|
||||
opt.actions.clone().into_boxed_slice()
|
||||
} else {
|
||||
vec![].into_boxed_slice()
|
||||
};
|
||||
insertion.next(m.expected, actions);
|
||||
}
|
||||
insertion.finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user