def run

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

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

1165# pos: the position of s's head. Once a match exists and no thread is live, the rest of s cannot change it.
1166def run(s: String, +prog: Trie<Inst>, +fuel: Nat, +init: List<&2, Maybe<&2, U32>>, +start: Maybe<&2, List<&2, Inst>>, +any: Bool, +pos: U32, st: Vm) -> Maybe<&2, List<&2, Maybe<&2, U32>>>:
1167  match s:
1168    case SNil{}:
1169      Vm{ths, best} = st
1170      run.end(scan(ths, prog, None{}, any, Sc{Nil{}, best, False{}}))
1171    case SCon{+c, +t}:
1172      match st:
1173        case Vm{Nil{}, Some{b}}:
1174          Some{b}
1175        case Vm{ths, best}:
1176          +p = (pos + 1 : U32)
1177          run(t, prog, fuel, init, start, any, p, run.step(Vm{ths, best}, prog, fuel, init, start, any, p, c, String.get(t, 0n)))

Uses (15)

Used by (1)