aboutsummaryrefslogtreecommitdiff
path: root/vendor/cabal-helper-0.8.1.2/tests/bkpregex/regex-indef/Regex.hs
blob: 506566b682a8fdbab82115e92eb170f258cf5f43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module Regex where

import Prelude hiding (null)
import Str
import Regex.Types

accept :: Reg -> Str -> Bool
accept Eps       u = null u
accept (Sym c)   u = u == singleton c
accept (Alt p q) u = accept p u || accept q u
accept (Seq p q) u =
    or [accept p u1 && accept q u2 | (u1, u2) <- splits u]
accept (Rep r) u =
    or [and [accept r ui | ui <- ps] | ps <- parts u]