Skip to content

Commit

Permalink
fix #79
Browse files Browse the repository at this point in the history
  • Loading branch information
dm0n3y committed Nov 8, 2024
1 parent 0890b2e commit fcf9679
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/core/material/Walk.re
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module T = {

let is_eq = w => List.for_all(Swing.is_eq, Chain.loops(w));
// note: stricter than !is_eq
let is_neq = (w: t) => Swing.is_neq(hd(w)); // && Swing.is_neq(ft(w));
let is_neq = (w: t) => Swing.is_neq(hd(w)) && Swing.is_neq(ft(w));
let is_valid = w => is_eq(w) || is_neq(w);

// let has_sort = w => List.exists(Swing.has_sort, strides(w));
Expand Down
12 changes: 11 additions & 1 deletion src/core/parser/Melder.re
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,17 @@ let connect_ineq =
let neq = () =>
connect_neq(~repair, ~onto=d, onto, ~fill, t)
|> Option.map(grouted => (grouted, onto));
Oblig.Delta.minimize(~to_zero=!repair, f => f(), [eq, neq]);
if (repair) {
open Options.Syntax;
// if repairing, then this means we're molding/remolding and our push of the
// current candidate token has reached the top of the local stack ie the nearest
// bidelimited container. prioritize maintaining the current bidelimited
// container if possible.
let/ () = neq();
eq();
} else {
Oblig.Delta.minimize(~to_zero=true, f => f(), [eq, neq]);
};
};

let connect =
Expand Down
10 changes: 7 additions & 3 deletions src/core/parser/Molder.re
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ let mold =
Token.is_empty(deferred)
? None
: Some(
Melder.push(deferred, ~fill, stack, ~onto=L)
|> Option.map(((grouted, stack)) => (deferred, grouted, stack))
|> Options.get_fail("bug: failed to push space"),
{
let (fill, slope) = Slope.Dn.unroll(fill);
let stack = Stack.cat(slope, stack);
Melder.push(deferred, ~fill, stack, ~onto=L)
|> Option.map(((grouted, stack)) => (deferred, grouted, stack))
|> Options.get_fail("bug: failed to push space");
},
);
};
5 changes: 5 additions & 0 deletions src/core/parser/Stack.re
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ type t = {

let empty = {slope: Slope.empty, bound: Bound.Root};

let cat = (slope: Slope.t, stack: t) => {
...stack,
slope: Slope.cat(slope, stack.slope),
};

let merge_hd = (~onto: Dir.t, t: Token.t, stack: t) =>
switch (stack) {
| {slope: [], bound: Root} => None
Expand Down

0 comments on commit fcf9679

Please sign in to comment.