def secs.go

bend-kit-jwt@0.11.0.1 · jwt.bend:176

import bend-kit-jwt@0.11.0.1/jwt.bend as Jwt
import Base

176# The JSON parser has checked the grammar, so only digits and one '.' need telling apart.
177def secs.go(s: String, +acc: U32, +frac: Bool, +point: Bool, +ok: Bool) -> Maybe<&2, U32>:
178  match s:
179    case SNil{}:
180      Bool.pick(Maybe<&2, U32>, ok, Some{secs.up(acc, frac)}, None{})
181    case SCon{Chr{+c}, t}:
182      +d = Bool.and(U32.is_le(48, c), U32.is_le(c, 57))
183      +dot = U32.is_eq(c, 46)
184      secs.go(t, Bool.pick(U32, Bool.or(point, Bool.not(d)), acc, secs.digit(acc, (c - 48 : U32))),
185        Bool.or(frac, Bool.and(point, Bool.and(d, U32.is_ne(c, 48)))), Bool.or(point, dot),
186        Bool.and(ok, Bool.or(d, Bool.and(dot, Bool.not(point)))))

Uses (15)

Used by (1)