def close.list

bolt@1.27.0.0 · src/rules/suspicious/empty.bend:162

import bolt@1.27.0.0/src/rules/suspicious/empty.bend as Empty
import Base
import bolt@1.27.0.0/src/syntax/lex.bend as Lex

162# a List.length's arguments, scanned to the `)` that closes them: the name
163# they end in and the tokens after that `)`; none when they end otherwise
164# or run out. done carries whether the last token read was that `)`.
165def close.list(toks: List<&2, Lex.Tok>, +dd: Nat, +ll: Last, done: Bool, got: Maybe<&2, Taken>) -> Maybe<&2, Taken>:
166  match toks:
167    case Nil{}:
168      got
169    case Con{Lex.Tok{+k, +t, l, c}, +rest}:
170      match done:
171        case True{}:
172          got
173        case False{}:
174          +here = close.here(k, dd)
175          close.list(rest, close.depth(k, dd), last.step(k, t, ll), here, Bool.pick(Maybe<&2, Taken>, here,
176            last.name(ll, rest), None{}))

Uses (12)

Used by (1)