Bind.walk: def of bolt@1.27.0.0 Import: import bolt@1.27.0.0/src/syntax/bind.bend as Bind Lines 787-815 of bolt@1.27.0.0/src/syntax/bind.bend: https://jend.leeeet.dev/read.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&start_line=787&end_line=815 import Base import bolt@1.27.0.0/src/syntax/lex.bend as Lex import bolt@1.27.0.0/src/syntax/tree.bend as Tree # the walk: one node in one mode, against an environment. It takes the node # apart as far as its head, and the plan above says what the head does in # this mode. Every recursive call is on a subtree (kids, body, gkids or # rest), never on n itself def walk(nn: Tree.Node, +mode: Mode, +env: List<&2, Bind>, +ns: Names, out: Out) -> W: match nn: case Tree.NCons{hd, +rest}: match hd: case Tree.Leaf{Lex.Tok{+k, +t, +l, +c}}: +keep = plan.keep(mode, k) +bb = plan.binder(mode, k, t, l, c, rest) +o1 = plan.recorded(plan.rec(mode, k, rest), bb, out) +o2 = plan.used(plan.use(mode, k, rest), t, l, c, env, ns, o1) +e2 = plan.enter(keep, plan.outer(mode), plan.push(mode, k, rest), bb, env) +r = walk(rest, plan.lmode(mode, k, rest), e2, ns, o2) W{Bool.pick(List<&2, Bind>, keep, env, env_of(r)), out_of(r)} case Tree.Group{Lex.Tok{_gk, gt, _gl, _gc}, gkids, _close}: +g = walk(gkids, plan.ginner(mode, gt), env, ns, out) walk(rest, plan.gnext(mode), Bool.pick(List<&2, Bind>, plan.gkeeps(mode), env_of(g), env), ns, out_of(g)) case Tree.Stmt{+sk, +kids, body}: +h = walk(kids, plan.kmode(mode, sk, env), env, ns, plan.marked(plan.mark_head(mode, sk), Tree.line(kids), env, out)) +b = walk(body, plan.bmode(mode, sk), env_of(h), ns, plan.marked(plan.mark_body(mode, sk), Tree.line(kids), env_of(h), out_of(h))) walk(rest, plan.snext(mode), Bool.pick(List<&2, Bind>, plan.scoped(mode, sk), env, env_of(h)), ns, out_of(b)) case _other: walk(rest, plan.skip(mode), env, ns, out) case _other: W{env, out} Uses (33): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=Bind https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=Mode https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=Names https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=Out https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=W https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=env_of https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=out_of https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.binder https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.bmode https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.enter https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.ginner https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.gkeeps https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.gnext https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.keep https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.kmode https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.lmode https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.mark_body https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.mark_head https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.marked https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.outer https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.push https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.rec https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.recorded https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.scoped https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.skip https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.snext https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.use https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/bind.bend&name=plan.used https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/lex.bend&name=Tok https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/tree.bend&name=Node https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/tree.bend&name=line