def unimported
bolt@1.27.0.0 · src/rules/style/space.bend:62
import bolt@1.27.0.0/src/rules/style/space.bend as Space
import Base
import bolt@1.27.0.0/src/syntax/lex.bend as Lex
import bolt@1.27.0.0/src/lazy/lazy.bend as Lazy
62
63
64
65def unimported(toks: List<&2, Lex.Tok>, start: Bool, cutting: Bool) -> List<&2, Lex.Tok>:
66 match toks:
67 case Nil{}:
68 Nil{}
69 case Con{Lex.Tok{Lex.TNewline{}, t, l, c}, rest}:
70 Lex.Tok{Lex.TNewline{}, t, l, c} <> unimported(rest, True{}, False{})
71 case Con{Lex.Tok{k, +t, l, c}, +rest}:
72 +cuts = Bool.or(cutting, Bool.and(start, String.eq(t, "import")))
73 Lazy.either(List<&2, Lex.Tok>, cuts, _u => unimported(rest, False{}, True{}),
74 _v => Lex.Tok{k, t, l, c} <> unimported(rest, False{}, False{}))