def first
import bolt@1.27.0.0/src/syntax/tree.bend as Treeimport Base
import bolt@1.27.0.0/src/syntax/lex.bend as Lex
54# the token a leaf holds; a group's open, a statement's first token
55def first(nn: Node) -> Maybe<&2, Lex.Tok>:
56 match nn:
57 case Leaf{tok}:
58 Some{tok}
59 case Group{open, kids, close}:
60 Some{open}
61 case Stmt{kind, kids, body}:
62 first(kids)
63 case NNil{}:
64 None{}
65 case NCons{h, t}:
66 first(h)