def literal
bolt@1.27.0.0 · src/rules/perf/strings.bend:47
import bolt@1.27.0.0/src/rules/perf/strings.bend as Strings
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
import bolt@1.27.0.0/src/rules/tokens.bend as T
47
48
49def literal(kids: Tree.Node) -> Maybe<&2, U32>:
50 match kids:
51 case Tree.NCons{Tree.Leaf{Lex.Tok{Lex.TStr{}, +t, l, c}}, rest}:
52 +w = T.width(t)
53 Bool.pick(Maybe<&2, U32>, terminated(t), Some{(w - 2 : U32)}, None{})
54 case other:
55 None{}