Scan.number.go: def of gralha-text-scan@0.1.0.1 Import: import gralha-text-scan@0.1.0.1/scan.bend as Scan Lines 184-205 of gralha-text-scan@0.1.0.1/scan.bend: https://jend.leeeet.dev/read.txt?path=gralha-text-scan@0.1.0.1/scan.bend&start_line=184&end_line=205 import Base # `c` is the character before `t`; `ok` says whether it was read, and the # parts are the ones after it. The next character is read when the stage # accepts it, and otherwise the parts are kept and the number stops there. def number.go(t: String, ok: Bool, +c: U32, mark: String, +stage: U32, +sign: F32, +mant: F32, +div: F32, +esign: F32, +ev: U32, +digits: Bool, +edigits: Bool) -> Number: match t ok: case t False{}: number.finish(SCon{Chr{c}, t}, mark, stage, sign, mant, div, esign, ev, digits, edigits) case SNil{} True{}: number.finish("", mark, stage, sign, mant, div, esign, ev, digits, edigits) case SCon{Chr{c2}, t2} True{}: +cc = c2 +k = number.class(cc) +read = number.accepts(k, stage, digits) +isDigit = read && U32.is_eq(k, 0) +inExp = U32.is_ge(stage, 3) +minus = read && U32.is_eq(k, 3) && U32.is_eq(cc, 45) +stage2 = choose(U32, read, number.stage(k, stage), stage) number.go(t2, read, cc, number.mark(read && U32.is_eq(stage2, 3), cc, mark), stage2, choose(F32, minus && U32.is_eq(stage, 0), F32.neg(1.0), sign), choose(F32, isDigit && Bool.not(inExp), (mant * 10.0 + U32.to_f32((cc - 48 : U32)) : F32), mant), choose(F32, isDigit && U32.is_eq(stage, 2), (div * 10.0 : F32), choose(F32, read && U32.is_eq(k, 1), 1.0, div)), choose(F32, minus && U32.is_eq(stage, 3), F32.neg(1.0), esign), choose(U32, isDigit && inExp, (ev * 10 + cc - 48 : U32), ev), digits || (isDigit && Bool.not(inExp)), edigits || (isDigit && inExp)) Uses (24): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.not https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.or https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Char https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.neg https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_ge https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_f32 https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=Number https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=choose https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=number.accepts https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=number.class https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=number.finish https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=number.mark https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=number.stage