def step

bolt@1.27.0.0 · src/syntax/lex.bend:294

import bolt@1.27.0.0/src/syntax/lex.bend as Lex
import Base
import bolt@1.27.0.0/src/lazy/lazy.bend as Lazy

294# one char: it continues the current token, or starts a new one. Only the
295# branch taken is built: the token is flushed (its text reversed, its kind
296# refined) once, where it ends, not on every char of it
297def step(+cc: Char, st: St) -> St:
298  St{+mode, +kind, +line, +col, +sl, +sc, +buf, +toks} = st
299  +cls = classify(cc)
300  +nl = is_newline(cc)
301  +line2 = Bool.pick(U32, nl, (line + 1 : U32), line)
302  +col2 = Bool.pick(U32, nl, 0, (col + 1 : U32))
303  Lazy.either(St, continues(mode, cls),
304    _u => St{after(mode, cls), kind, line2, col2, sl, sc, cc <> buf, toks},
305    _v => St{begin.mode(cls), begin.kind(cls), line2, col2, line, col, [cc], flush(kind, sl, sc, buf, toks)})

Uses (14)

Used by (1)