def tag.chars
yaml-for-bend@0.1.1.0 · scan.bend:1158
import yaml-for-bend@0.1.1.0/scan.bend as Scan
import Base
1158def tag.chars(s: String, +uri: Bool, +pending: Nat) -> Taken:
1159 match s:
1160 case SNil{}:
1161 Taken{"", 0n}
1162 case SCon{+c, +t}:
1163 match pending:
1164 case 1n+k:
1165 taken.skip(tag.chars(t, uri, k))
1166 case 0n:
1167 +esc = Bool.and(Char.is_eq(c, '%'), Bool.and(is_hex(peek(t, 0n)), is_hex(peek(t, 1n))))
1168 +ok = Bool.pick(Bool, uri, is_uri(c), is_tag(c))
1169 took.or(Bool.not(Bool.or(esc, ok)),
1170 u => taken.cons(Bool.pick(Char, esc, Chr{hex.value(String.take(t, 2n), 0)}, c), 1n,
1171 tag.chars(t, uri, Bool.pick(Nat, esc, 2n, 0n))))