def top_has
bolt@1.27.0.0 · src/rules/table.bend:24
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
24
25def top_has(nn: Tree.Node, +want: String) -> Bool:
26 match nn:
27 case Tree.NCons{Tree.Group{open, kids, close}, rest}:
28 top_has(rest, want)
29 case Tree.NCons{Tree.Leaf{Lex.Tok{k, +t, l, c}}, rest}:
30 +more = top_has(rest, want)
31 Bool.or(String.eq(t, want), more)
32 case Tree.NCons{h, rest}:
33 top_has(rest, want)
34 case other:
35 False{}