def lets
bolt@1.27.0.0 · src/rules/table.bend:188
import bolt@1.27.0.0/src/rules/table.bend as Table
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
188
189
190
191def lets(nn: Tree.Node, +live: List<&2, String>, acc: List<&2, String>) -> List<&2, String>:
192 match nn:
193 case Tree.NCons{Tree.Stmt{kind, +kids, body}, rest}:
194 +next = rebind(bind_name(kids, False{}, False{}, ""), built(bind_rhs(kids)), live)
195 lets(rest, next, lets(body, live, lets(kids, live, acc)))
196 case Tree.NCons{Tree.Group{open, +kids, close}, rest}:
197 lets(rest, live, lets(kids, live, acc))
198 case Tree.NCons{Tree.Leaf{Lex.Tok{Lex.TName{}, +t, +l, +c}}, rest}:
199 lets(rest, live, use_at(t, l, c, live, acc))
200 case Tree.NCons{h, rest}:
201 lets(rest, live, acc)
202 case other:
203 acc