def entity.take
gralha-xml-doc@0.1.0.1 · xml.bend:26
import gralha-xml-doc@0.1.0.1/xml.bend as Xml
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
26def entity.take(s: String, +name: String, +n: U32) -> Step:
27 match s:
28 case SNil{}: Step{2, 0, name, ""}
29 case SCon{Chr{c}, t}:
30 +ch = c
31 +tail = t
32 U.branch(Step, U32.is_eq(ch, 38), _ => Step{1, 0, name, tail},
33 _ => U.branch(Step, U32.is_lt(n, 12) && (U.digit(ch) || (U32.is_ge(ch, 65) && U32.is_le(ch, 90)) || (U32.is_ge(ch, 97) && U32.is_le(ch, 122)) || U32.is_eq(ch, 35)),
34 _ => entity.take(tail, SCon{Chr{ch}, name}, (n + 1 : U32)), _ => Step{2, 0, name, SCon{Chr{ch}, tail}}))