def Parse.digits
bend-trace-context@0.2.0.0 · trace_context.bend:353
import bend-trace-context@0.2.0.0/trace_context.bend as TraceContext
import Base
import bend-trace-context@0.2.0.0/src/hex.bend as Hex
import bend-trace-context@0.2.0.0/src/digits.bend as Digits
353
354
355
356def Parse.digits(n: Nat, text: String, offset: Nat) ->
357 Result<&2, &2, Error, Parsed<n>>:
358 match n:
359 case 0n:
360 Done{Parsed{Digits.DNil{}, text}}
361 case 1n+p:
362 match text:
363 case SNil{}:
364 Fail{UnexpectedEnd{offset}}
365 case SCon{char, tail}:
366 +at = offset
367 do Result<&2, &2, Error, Parsed<1n+p>>:
368 digit : Hex.Digit <- Parse.digit(char, at)
369 parsed : Parsed<p> <- Parse.digits(p, tail, 1n+at)
370 return Parsed.prepend(p, digit, parsed)