def search.text

bolt@1.27.0.0 · src/rules/correctness/pick.bend:151

import bolt@1.27.0.0/src/rules/correctness/pick.bend as Pick
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

151# the node's tokens, each then a space (a group's open, not its close)
152def search.text(nn: Tree.Node) -> String:
153  match nn:
154    case Tree.Leaf{Lex.Tok{_k, t, _l, _c}}:
155      t ++ " "
156    case Tree.Group{Lex.Tok{_k, o, _l, _c}, kids, _cl}:
157      o ++ " " ++ search.text(kids)
158    case Tree.Stmt{_k, kids, body}:
159      +a = search.text(kids)
160      +b = search.text(body)
161      a ++ b
162    case Tree.NCons{h, t}:
163      +a = search.text(h)
164      +b = search.text(t)
165      a ++ b
166    case Tree.NNil{}:
167      ""

Uses (4)

Used by (2)