Skip to content

Commit

Permalink
rm space merging pathway
Browse files Browse the repository at this point in the history
  • Loading branch information
dm0n3y committed Jul 24, 2024
1 parent 2991d87 commit b959f76
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/core/parser/Melder.re
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ let push_bound = (~repair=false, t: Token.t, ~fill=Cell.empty, bound, ~onto) =>
let push =
(~repair=false, t: Token.t, ~fill=Cell.empty, slope, ~bound, ~onto)
: option(Melded.t) =>
switch (Slope.merge_hd(t, ~caret=?Cell.is_caret(fill), slope, ~onto)) {
switch (Slope.merge_hd(t, slope, ~onto)) {
| Some(slope) => Some(Neq(slope))
| None =>
switch (t.mtrl) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/structure/Cell.re
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ let get_spc = (c: t) =>
};
// raises Invalid_argument if inputs are not space cells
let merge_spc = (l: t, r: t) => {
let get = Options.get_exn(Invalid_argument("Cell.merge"));
let get = Options.get_exn(Invalid_argument("Cell.merge_spc"));
let spc_l = get(get_spc(l));
let spc_r = get(get_spc(r));
let marks_l =
Expand Down
4 changes: 2 additions & 2 deletions src/core/structure/Slope.re
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ let pull = (~from: Dir.t, slope: t): option((Token.t, t)) =>
Some((tok, slope));
};

let merge_hd = (~onto: Dir.t, t: Token.t, ~caret=?, slope: t): option(t) =>
let merge_hd = (~onto: Dir.t, t: Token.t, slope: t): option(t) =>
switch (slope) {
| [] => None
| [hd, ...tl] =>
Terr.merge_hd(~onto, t, ~caret?, hd) |> Option.map(hd => [hd, ...tl])
Terr.merge_hd(~onto, t, hd) |> Option.map(hd => [hd, ...tl])
};

// Dn and Up slopes named based on left-to-right order of terraces
Expand Down
6 changes: 3 additions & 3 deletions src/core/structure/Terr.re
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ let unlink = (terr: t) =>
| Error(tok) => (tok, terr.cell, None)
};

let merge_hd = (~onto: Dir.t, t: Token.t, ~caret=?, terr: t) => {
let merge_hd = (~onto: Dir.t, t: Token.t, terr: t) => {
open Options.Syntax;
let (l, r) = Dir.order(onto, (hd(terr), t));
let+ zipped = Token.merge(~save_cursor=Dir.toggle(onto), l, ~caret?, r);
put_hd(zipped, terr);
let+ merged = Token.merge(~save_cursor=Dir.toggle(onto), l, r);
put_hd(merged, terr);
};
// module Tl = {
// // a terrace minus its hd token
Expand Down
10 changes: 1 addition & 9 deletions src/core/structure/Token.re
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,12 @@ module Molded = {
);
};

let merge = (~save_cursor=?, l: t, ~caret=?, r: t) =>
let merge = (~save_cursor=?, l: t, r: t) =>
if (l.id == r.id) {
switch (save_cursor) {
| None => Some(clear_marks(l))
| Some(d) => Some(Dir.pick(d, (l, r)))
};
} else if (l.mtrl == Space() && r.mtrl == Space()) {
let (l, r) =
switch (save_cursor) {
| None => (clear_marks(l), clear_marks(r))
| Some(L) => (l, clear_marks(r))
| Some(R) => (clear_marks(l), r)
};
Some(cat(l, ~caret?, r));
} else {
None;
};
Expand Down

0 comments on commit b959f76

Please sign in to comment.