def header

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

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

1005# The indicators after "|" or ">", in either order.
1006def header(+cur: Cur) -> Head:
1007  +s = cur.s(cur)
1008  +c0 = peek(s, 0n)
1009  +c1 = peek(s, 1n)
1010  +ch0 = chomp.of(c0)
1011  +ch1 = chomp.of(c1)
1012  +d0 = Bool.and(Char.is_digit(c0), Bool.not(Char.is_eq(c0, '0')))
1013  +d1 = Bool.and(Char.is_digit(c1), Bool.not(Char.is_eq(c1, '0')))
1014  when(Head, Bool.or(Char.is_eq(c0, '0'), Bool.and(is_some.chomp(ch0), Char.is_eq(c1, '0'))),
1015    u => HeadBad{"found an indentation indicator equal to 0 while scanning a block scalar"},
1016    u => when(Head, Bool.and(is_some.chomp(ch0), d1), u => head.end(chomp.or(ch0, Clip{}), digit.value(c1), adv.n(2n, cur)),
1017      u => when(Head, is_some.chomp(ch0), u => head.end(chomp.or(ch0, Clip{}), 0n, adv(cur)),
1018        u => when(Head, Bool.and(d0, is_some.chomp(ch1)), u => head.end(chomp.or(ch1, Clip{}), digit.value(c0), adv.n(2n, cur)),
1019          u => when(Head, d0, u => head.end(Clip{}, digit.value(c0), adv(cur)), u => head.end(Clip{}, 0n, cur))))))

Uses (19)

Used by (1)