Skip to content

Commit

Permalink
comment out old logs, add new logs for minijs
Browse files Browse the repository at this point in the history
  • Loading branch information
dm0n3y committed Jan 30, 2025
1 parent ea2af1b commit 445efe3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 39 deletions.
22 changes: 10 additions & 12 deletions src/core/editor/Modify.re
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ let mold =
};

let rec remold = (~fill=Cell.dirty, ctx: Ctx.t): (Cell.t, Ctx.t) => {
P.log("--- Modify.remold");
P.show("fill", Cell.show(fill));
P.show("ctx", Ctx.show(ctx));
// P.log("--- Modify.remold");
// P.show("fill", Cell.show(fill));
// P.show("ctx", Ctx.show(ctx));
let ((l, r), tl) = Ctx.unlink_stacks(ctx);
switch (Molder.remold(~fill, (l, r))) {
// ( 1 + 2 ) + 3 ) + 4
Expand All @@ -152,9 +152,9 @@ let rec remold = (~fill=Cell.dirty, ctx: Ctx.t): (Cell.t, Ctx.t) => {
|> remold(~fill)
// # 1 + ( <> >)> #
| Ok((dn, fill)) =>
P.log("--- Modify.remold/done");
P.show("dn", Slope.Dn.show(dn));
P.show("fill", Cell.show(fill));
// P.log("--- Modify.remold/done");
// P.show("dn", Slope.Dn.show(dn));
// P.show("fill", Cell.show(fill));
let bounds = (l.bound, r.bound);
// Melder.debug := true;
let cell = Melder.complete_bounded(~bounds, ~onto=L, dn, ~fill);
Expand Down Expand Up @@ -374,8 +374,8 @@ let insert_toks =
let meld_remold =
(~expanding=false, prev, tok: Token.t, next, ctx: Ctx.t)
: option((Cell.t, Ctx.t)) => {
P.log("--- Modify.meld_remold");
open Options.Syntax;
open Options.Syntax; // P.log("--- Modify.meld_remold");

// P.log("--- Modify.meld_remold");
// P.show("prev", Cell.show(prev));
// P.sexp("tok", Token.sexp_of_t(tok));
Expand All @@ -396,12 +396,12 @@ let meld_remold =
&& l.slope == []
);
if (is_redundant) {
P.log("--- Modify.meld_remold/is_redundant");
// P.log("--- Modify.meld_remold/is_redundant");
Effects.remove(tok);
let fill = Cell.Space.merge(prev, ~fill=Cell.degrouted, next);
Some(remold(~fill, ctx));
} else {
P.log("--- Modify.meld_remold/not_redundant");
// P.log("--- Modify.meld_remold/not_redundant");
let connected = Stack.connect(Effects.insert(tok), grouted, l);
let ctx =
connected.bound == l.bound
Expand All @@ -416,8 +416,6 @@ let meld_remold =
? ctx |> Ctx.push(~onto=L, Token.space()) |> Ctx.trim_space(~side=R)
: ctx;
let remolded = remold(~fill=next, ctx);
P.show("remolded cell", Cell.show(fst(remolded)));
P.show("remolded ctx", Ctx.show(snd(remolded)));
// P.log("--- meld_remold");
// P.show("tok", Token.show(tok));
// P.show("ctx", Ctx.show(ctx));
Expand Down
2 changes: 1 addition & 1 deletion src/core/parser/Grouter.re
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ let fill_swing = (cs: Cells.t, sw: Walk.Swing.t, ~from: Dir.t) => {
r;
}
: {
P.show("None", "None");
None;
// P.show("None", "None");
};
| Grout(s)
| Tile(((_, s), _)) =>
Expand Down
11 changes: 8 additions & 3 deletions src/core/parser/Melder.re
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ let complete_terr = (~onto: Dir.t, ~fill=Cell.empty, terr: Terr.t): Cell.t => {
| None =>
assert(!Cell.is_empty(fill));
print_endline("warning: dropping fill " ++ Cell.show(fill));
P.log("--- Melder.complete_terr/None");
P.sexp("fill", Cell.sexp_of_t(fill));
P.sexp("terr", Terr.sexp_of_t(terr));
P.log("exited =");
exited |> List.iter(w => P.show("w", Walk.show(w)));
// walker bug if no exits
// let exited = List.hd(exited);
let grouted =
Expand All @@ -61,8 +66,8 @@ let complete_slope = (~onto: Dir.t, ~fill=Cell.empty) =>

let complete_bounded =
(~bounds as (l, r), ~onto: Dir.t, ~fill=Cell.empty, slope) => {
P.log("--- Melder.complete_bounded");
P.show("fill", Cell.show(fill));
// P.log("--- Melder.complete_bounded");
// P.show("fill", Cell.show(fill));
// from/onto terminology here very confusing...
// if (debug^) {
// P.log("--- Melder.complete_bounded");
Expand All @@ -74,7 +79,7 @@ let complete_bounded =
// };
let (bd_onto, bd_from) = Dir.order(onto, (l, r));
let fill = complete_slope(~onto, ~fill, slope);
P.show("completed fill", Cell.show(fill));
// P.show("completed fill", Cell.show(fill));
let fc_onto = bd_onto |> Bound.map(t => Terr.face(t).mtrl);
let fc_from = bd_from |> Bound.map(t => Terr.face(t).mtrl);
// if (debug^) {
Expand Down
49 changes: 26 additions & 23 deletions src/core/parser/Molder.re
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ let candidates = (t: Token.Unmolded.t): list(Token.t) =>
);

let complete_pending_ghosts = (~bounds, l: Stack.t, ~fill) => {
P.log("--- Molder.complete_pending_ghosts");
P.show("l", Stack.show(l));
P.show("fill", Cell.show(fill));
// P.log("--- Molder.complete_pending_ghosts");
// P.show("l", Stack.show(l));
// P.show("fill", Cell.show(fill));
let (cell, effs) =
Effects.dry_run(
() => {
Grouter.dbg := true;
// Grouter.dbg := true;
let r = Melder.complete_bounded(~bounds, ~onto=L, l.slope, ~fill);
Grouter.dbg := false;
// Grouter.dbg := false;
r;
},
(),
);
P.show("completed cell", Cell.show(cell));
// P.show("completed cell", Cell.show(cell));
// hack(?) to avoid completion if no new ghosts are generated. if only
// grout are generated, then we can generate them later as needed at the
// end of remolding. better to delay their generation bc there may already
Expand All @@ -74,15 +74,18 @@ let complete_pending_ghosts = (~bounds, l: Stack.t, ~fill) => {
| Remove(_) => true,
)
? {
P.log("--- Molder.complete_pending_ghosts/not completing");
(l, fill);
(
// P.log("--- Molder.complete_pending_ghosts/not completing");
l,
fill,
);
}
// P.log("--- Molder.complete_pending_ghosts/completing");
: {
P.log("--- Molder.complete_pending_ghosts/completing");
Effects.commit(effs);
let (fill, slope) = Slope.Dn.unroll(cell);
P.show("unrolled fill", Cell.show(fill));
P.show("unrolled slope", Slope.show(slope));
// P.show("unrolled fill", Cell.show(fill));
// P.show("unrolled slope", Slope.show(slope));
({...l, slope}, fill);
};
};
Expand Down Expand Up @@ -143,19 +146,19 @@ let rec mold =
and remold =
(~fill, (l, r): Stack.Frame.t)
: Result.t((Slope.Dn.t, Cell.t), (Cell.t, Stack.Frame.t)) => {
P.log("--- Molder.remold");
P.show("fill", Cell.show(fill));
P.show("(l, r)", Stack.Frame.show((l, r)));
// P.log("--- Molder.remold");
// P.show("fill", Cell.show(fill));
// P.show("(l, r)", Stack.Frame.show((l, r)));
let bounds = (l.bound, r.bound);
switch (r.slope) {
| [] =>
P.log("--- Molder.remold/done");
P.show("l", Stack.show(l));
P.show("fill", Cell.show(fill));
Ok((l.slope, fill));
// P.log("--- Molder.remold/done");
// P.show("l", Stack.show(l));
// P.show("fill", Cell.show(fill));
Ok((l.slope, fill))
| [hd, ...tl] =>
P.log("--- Molder.remold/continue");
P.show("hd", Terr.show(hd));
// P.log("--- Molder.remold/continue");
// P.show("hd", Terr.show(hd));
// insert any pending ghosts if next terr has newlines
let (l, fill) =
Terr.tokens(hd)
Expand All @@ -173,9 +176,9 @@ and remold =
(c, up);
})
|> Option.value(~default=Slope.Up.unroll(hd.cell));
P.log("--- Molder.remold/continue/molding");
P.show("l", Stack.show(l));
P.show("fill", Cell.show(fill));
// P.log("--- Molder.remold/continue/molding");
// P.show("l", Stack.show(l));
// P.show("fill", Cell.show(fill));
// P.show("hd_w", Token.show(hd_w));
switch (mold(~re=true, l, ~fill, Token.unmold(hd_w))) {
| Error(fill) =>
Expand Down

0 comments on commit 445efe3

Please sign in to comment.