def tally

bolt@1.27.0.0 · src/rules/perf/chars.bend:35

import bolt@1.27.0.0/src/rules/perf/chars.bend as Chars
import Base
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
import bolt@1.27.0.0/src/rules/tokens.bend as T

35# the character-literal arms among a match's statements
36def tally(body: Tree.Node, +nn: U32) -> U32:
37  match body:
38    case Tree.NCons{Tree.Stmt{Tree.SCase{}, kids, b}, rest}:
39      +k = literal(T.pattern(kids))
40      tally(rest, (nn + k : U32))
41    case Tree.NCons{h, rest}:
42      tally(rest, nn)
43    case other:
44      nn

Uses (6)

Used by (1)