regex-1.0.1.0: Toolkit for regex-base

Safe HaskellNone
LanguageHaskell2010

Text.RE.TestBench

Contents

Synopsis

The Test Bench Tutorial

This API module provides a test bench for developing, documenting and testing regex RE macros.

See the tutorials at http://re-tutorial-testbench.regex.uk

The Test Bench

type MacroEnv = HashMap MacroID MacroDescriptor Source #

each macro can reference others, the whole environment being required for each macro, so we use a Lazy HashMap

data MacroDescriptor Source #

describes a macro, giving the text of the RE and a si=ummary description

Constructors

MacroDescriptor 

Fields

newtype RegexSource Source #

a RE that should work for POSIX and PCRE with open brackets ('(') represented as follows: ( mere symbol (?: used for grouping only, not for captures (}: used for captures only, not for grouping (]: used for captures and grouping ( do not modify

Constructors

RegexSource 

Fields

data WithCaptures Source #

do we need the captures in the RE or whould they be stripped out where possible

Constructors

InclCaptures

include all captures

ExclCaptures

remove captures where possible

data RegexType Source #

what flavour of regex are we dealing with

isTDFA :: RegexType -> Bool Source #

test RegexType for TDFA/PCREness

isPCRE :: RegexType -> Bool Source #

test RegexType for TDFA/PCREness

Constructing a MacrosEnv

mkMacros :: (Monad m, Functor m) => (String -> m r) -> RegexType -> WithCaptures -> MacroEnv -> m (Macros r) Source #

construct a macro table suitable for use with the RE compilers

Formatting Macros

formatMacroTable :: RegexType -> MacroEnv -> String Source #

format a macros table as a markdown table

formatMacroSummary :: RegexType -> MacroEnv -> MacroID -> String Source #

generate a plain text summary of a macro

formatMacroSources :: RegexType -> WithCaptures -> MacroEnv -> String Source #

list the source REs for each macro in plain text

formatMacroSource :: RegexType -> WithCaptures -> MacroEnv -> MacroID -> String Source #

list the source of a single macro in plain text

Formatting Macros

testMacroEnv :: String -> RegexType -> MacroEnv -> IO Bool Source #

test that a MacroEnv is passing all of its built-in tests

The Parsers

The Match Type

data Match a Source #

the result of matching a RE to a text once (with ?=~), retaining the text that was matched against

Instances

Functor Match Source # 

Methods

fmap :: (a -> b) -> Match a -> Match b #

(<$) :: a -> Match b -> Match a #

(RegexContext regex source (AllTextSubmatches (Array Int) (source, (Int, Int))), RegexLike regex source) => RegexContext regex source (Match source) Source #

this instance hooks Match into regex-base: regex consumers need not worry about any of this

Methods

match :: regex -> source -> Match source #

matchM :: Monad m => regex -> source -> m (Match source) #

Eq a => Eq (Match a) Source # 

Methods

(==) :: Match a -> Match a -> Bool #

(/=) :: Match a -> Match a -> Bool #

Show a => Show (Match a) Source # 

Methods

showsPrec :: Int -> Match a -> ShowS #

show :: Match a -> String #

showList :: [Match a] -> ShowS #