def pl.blank

yaml-for-bend@0.1.1.0 · scan.bend:740

import yaml-for-bend@0.1.1.0/scan.bend as Scan
import Base
import yaml-for-bend@0.1.1.0/token.bend as T

740# Between words: blanks and breaks wait to join the text; then the next word
741# starts, unless the scalar ended (less indented, a document marker, a
742# comment, or the end). A tab may not stand where indentation belongs on a
743# line that goes on.
744def pl.blank(cur: Cur, +acc: String, +end: T.Mark, +ws: String, +lead: Bool, +brks: Nat, +bad: Bool, +ind: Nat, +flow: Bool, +start: T.Mark) -> Pl:
745  match cur:
746    case Cur{+s, +at, +left}:
747      +c = peek(s, 0n)
748      +next = {Cur{String.drop(s, 1n), past(at, c), Nat.sub(left, 1n)} : Cur}
749      +here = {Cur{s, at, left} : Cur}
750      +col = T.mark.col(at)
751      +done = Bool.or(Bool.or(is_end(c), Bool.and(Bool.not(flow), Nat.is_lt(col, ind))),
752        Bool.or(Bool.and(Nat.is_eq(col, 0n), is_marker(s)), Char.is_eq(c, '#')))
753      +tabbed = Bool.and(Bool.and(lead, Char.is_eq(c, '\t')), Nat.is_lt(col, ind))
754      Bool.pick(Pl, is_blank(c), Pl{next, acc, end, Bool.pick(String, lead, ws, SCon{c, ws}), lead, brks, False{}, Bool.or(bad, tabbed)},
755        Bool.pick(Pl, is_break(c), Pl{next, acc, end, Bool.pick(String, lead, ws, ""), True{}, Bool.pick(Nat, lead, 1n+brks, brks), False{}, False{}},
756          Bool.pick(Pl, done, PlDone{here, acc, end, lead},
757            Bool.pick(Pl, bad, PlBad{T.Error{"found a tab character that violates indentation while scanning a plain scalar", start, T.Syntax{}}},
758              Pl{here, acc, end, ws, lead, brks, True{}, False{}}))))

Uses (25)

Used by (1)