def rev.candidates

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

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

2188def rev.candidates(fuel: Nat, r: RevPhase, +needle: String, +bits: Bits) -> RevFound:
2189  match fuel:
2190    case 0n:
2191      rev.abort(r)
2192    case 1n+f:
2193      match r:
2194        case Seek{hit, b, best}:
2195          match hit:
2196            case None{}:
2197              RevFound{b, best, True{}}
2198            case Some{+i}:
2199              Bytes.Bytes{+len, a} = b
2200              rev.candidates(f, Check{rev.bits.run(a, (i + 1 : U32), bits), len, i, best}, needle, bits)
2201        case Check{Rv{a, found, ascii}, +len, +at, best}:
2202          match ascii:
2203            case False{}:
2204              RevFound{Bytes.Bytes{len, a}, best, False{}}
2205            case True{}:
2206              rev.candidates(f, rev.seek(Bytes.find.from(Bytes.Bytes{len, a}, needle, (at + 1 : U32)), rev.min(found, best)), needle, bits)

Uses (16)

Used by (1)