def called

bolt@1.27.0.0 · src/rules/pedantic/rewalk.bend:373

import bolt@1.27.0.0/src/rules/pedantic/rewalk.bend as Rewalk
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

373# every name a node calls
374def called(nn: Tree.Node) -> List<&2, String>:
375  match nn:
376    case Tree.NCons{Tree.Leaf{Lex.Tok{k, +t, l, c}}, Tree.NCons{Tree.Group{Lex.Tok{_, +o, _, _}, +kids, _}, rest}}:
377      +more = List.concat(&2, String, [called(kids), called(rest)])
378      Bool.pick(List<&2, String>, String.eq(o, "("), t <> more, more)
379    case Tree.NCons{Tree.Group{open, +kids, close}, rest}:
380      List.concat(&2, String, [called(kids), called(rest)])
381    case Tree.NCons{Tree.Stmt{kind, +kids, body}, rest}:
382      List.concat(&2, String, [called(kids), called(body), called(rest)])
383    case Tree.NCons{h, rest}:
384      called(rest)
385    case other:
386      Nil{}

Uses (7)

Used by (1)