def defs

bolt@1.27.0.0 · src/rules/calls.bend:25

import bolt@1.27.0.0/src/rules/calls.bend as Calls
import Base
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
import bolt@1.27.0.0/src/syntax/bind.bend as Bind

25# the defs of a parsed source, in order
26def defs(root: Tree.Node) -> List<&2, Def>:
27  match root:
28    case Tree.NCons{Tree.Stmt{Tree.SDef{}, +kids, body}, rest}:
29      defs.push(Bind.declared(kids), kids, body, defs(rest))
30    case Tree.NCons{h, rest}:
31      defs(rest)
32    case other:
33      Nil{}

Uses (6)

Used by (13)