def finish
import emerging-ezjson@1.3.0.0/src/lex.bend as Leximport Base
302# the tokens, in order; text that ends inside a string or a word ends in TBad
303# when the string was not closed
304def finish(st: Lex) -> List<&2, Tok>:
305 Lex{mode, buf, toks} = st
306 match mode:
307 case Idle{}:
308 List.reverse(&2, Tok, toks)
309 case Word{}:
310 List.reverse(&2, Tok, TWord{text(buf)} <> toks)
311 case other:
312 List.reverse(&2, Tok, TBad{} <> toks)