def runb

bend-kit-regex@0.8.0.0 · regex.bend:1465

import bend-kit-regex@0.8.0.0/regex.bend as Regex
import Base

1465# fuel: each step eats at least one byte, and the last one sees DEnd.
1466def runb(fuel: Nat, r: Rb, +len: U32, +prog: Trie<Inst>, +cfuel: Nat, +init: List<&2, Maybe<&2, U32>>, +start: Maybe<&2, List<&2, Inst>>, +asc: Maybe<&2, Asc>, +any: Bool) -> Array<U32> & Maybe<&2, List<&2, Maybe<&2, U32>>>:
1467  match fuel:
1468    case 0n:
1469      Rb{a, i, d, st} = r
1470      (a, None{})
1471    case 1n+f:
1472      Rb{a, +i, d, st} = r
1473      match d:
1474        case DEnd{}:
1475          Vm{ths, best} = st
1476          (a, run.end(scan(ths, prog, None{}, any, Sc{Nil{}, best, False{}})))
1477        case Dc{+c, +w}:
1478          match st:
1479            case Vm{Nil{}, Some{b}}:
1480              (a, Some{b})
1481            case Vm{Nil{}, None{}}:
1482              runb(f, rb.idle(asc, a, len, (i + w : U32), c, prog, cfuel, init, start, any), len, prog, cfuel, init, start, asc, any)
1483            case Vm{ths, best}:
1484              +j = (i + w : U32)
1485              runb(f, rb.step(dec(a, len, j), j, Vm{ths, best}, c, prog, cfuel, init, start, any), len, prog, cfuel, init, start, asc, any)

Uses (21)

Used by (2)