def leaves.go
bolt@1.27.0.0 · src/syntax/tree.bend:106
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
import Base
import bolt@1.27.0.0/src/syntax/lex.bend as Lex
106def leaves.go(nn: Node, acc: List<&2, Lex.Tok>) -> List<&2, Lex.Tok>:
107 match nn:
108 case Leaf{tok}:
109 tok <> acc
110 case Group{open, kids, close}:
111 leaf_close(close, leaves.go(kids, open <> acc))
112 case Stmt{kind, kids, body}:
113 leaves.go(body, leaves.go(kids, acc))
114 case NNil{}:
115 acc
116 case NCons{h, t}:
117 leaves.go(t, leaves.go(h, acc))