def skip.go

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

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

641# Blanks, comments and line breaks before a token. A "#" starts a comment
642# after a blank or at a line's start (+gap+). A line break in block context
643# lets a simple key start. Along the way: whether a tab came on the token's
644# line (+tab+), whether a line break came (+nl+), the spaces that start the
645# token's line (+sp+, while +lead+), and whether a tab stood where block
646# indentation belongs (+bad+).
647def skip.go(s: String, +at: T.Mark, +left: Nat, +flow: Bool, +ind: Nat, +allowed: Bool, +comment: Bool, +gap: Bool,
648            +tab: Bool, +nl: Bool, +lead: Bool, +sp: Nat, +bad: Bool) -> Skipped:
649  match s:
650    case SNil{}:
651      Skipped{Cur{SNil{}, at, left}, allowed, tab, nl, sp, False{}}
652    case SCon{+c, +t}:
653      +brk = is_break(c)
654      +space = Char.is_eq(c, ' ')
655      +htab = Char.is_eq(c, '\t')
656      +eat = Bool.or(Bool.or(brk, comment), Bool.or(Bool.or(space, htab), Bool.and(Char.is_eq(c, '#'), gap)))
657      skip.or(eat,
658        u => skip.go(t, past(at, c), Nat.sub(left, 1n), flow, ind, Bool.or(allowed, Bool.and(brk, Bool.not(flow))),
659          Bool.and(Bool.not(brk), Bool.or(comment, Char.is_eq(c, '#'))), True{},
660          Bool.and(Bool.not(brk), Bool.or(tab, htab)), Bool.or(nl, brk), Bool.or(brk, Bool.and(lead, Bool.or(space, htab))),
661          Bool.pick(Nat, brk, 0n, Bool.pick(Nat, Bool.and(Bool.and(lead, space), Bool.not(tab)), 1n+sp, sp)),
662          Bool.and(Bool.not(brk), Bool.or(bad, Bool.and(Bool.and(htab, lead), Bool.and(Bool.not(flow), Nat.is_lt(1n+sp, ind)))))),
663        Skipped{Cur{SCon{c, t}, at, left}, allowed, tab, nl, sp, bad})

Uses (17)

Used by (1)