def run

yaml-for-bend@0.1.1.0 · re.bend:79

import yaml-for-bend@0.1.1.0/re.bend as Re
import Base

79def run(fuel: Nat, ps: List<&2, Pat>, +s: String) -> Bool:
80  match fuel:
81    case 0n:
82      False{}
83    case 1n+(+k):
84      match ps:
85        case Nil{}:
86          String.is_empty(s)
87        case Con{p, +rest}:
88          match p:
89            case One{cls}:
90              match s:
91                case SNil{}:
92                  False{}
93                case SCon{+c, t}:
94                  and.then(test(cls, c), u => run(k, rest, t))
95            case Opt{+q}:
96              or.else(run(k, q <> rest, s), u => run(k, rest, s))
97            case Star{+q}:
98              or.else(run(k, q <> Star{q} <> rest, s), u => run(k, rest, s))
99            case Plus{+q}:
100              run(k, q <> Star{q} <> rest, s)
101            case Alt{alts}:
102              match alts:
103                case Nil{}:
104                  False{}
105                case Con{a, others}:
106                  or.else(run(k, List.append(&2, Pat, a, rest), s), u => run(k, Alt{others} <> rest, s))

Uses (10)

Used by (1)