Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type MacroEnv = HashMap MacroID MacroDescriptor
- data MacroDescriptor = MacroDescriptor {
- macroSource :: !RegexSource
- macroSamples :: ![String]
- macroCounterSamples :: ![String]
- macroTestResults :: ![TestResult]
- macroParser :: !(Maybe FunctionID)
- macroDescription :: !String
- newtype RegexSource = RegexSource {}
- data WithCaptures
- data RegexType
- isTDFA :: RegexType -> Bool
- isPCRE :: RegexType -> Bool
- presentRegexType :: RegexType -> String
- mkMacros :: (Monad m, Functor m) => (String -> m r) -> RegexType -> WithCaptures -> MacroEnv -> m (Macros r)
- formatMacroTable :: RegexType -> MacroEnv -> String
- formatMacroSummary :: RegexType -> MacroEnv -> MacroID -> String
- formatMacroSources :: RegexType -> WithCaptures -> MacroEnv -> String
- formatMacroSource :: RegexType -> WithCaptures -> MacroEnv -> MacroID -> String
- testMacroEnv :: String -> RegexType -> MacroEnv -> IO Bool
- runTests :: (Eq a, Show a) => RegexType -> (String -> Maybe a) -> [(String, a)] -> MacroEnv -> MacroID -> MacroDescriptor -> MacroDescriptor
- runTests' :: (Eq a, Show a) => RegexType -> (Match String -> Maybe a) -> [(String, a)] -> MacroEnv -> MacroID -> MacroDescriptor -> MacroDescriptor
- parseInteger :: Replace a => a -> Maybe Int
- parseHex :: Replace a => a -> Maybe Int
- parseDouble :: Replace a => a -> Maybe Double
- parseString :: Replace a => a -> Maybe Text
- parseSimpleString :: Replace a => a -> Maybe Text
- parseDate :: Replace a => a -> Maybe Day
- parseSlashesDate :: Replace a => a -> Maybe Day
- parseTimeOfDay :: Replace a => a -> Maybe TimeOfDay
- parseTimeZone :: Replace a => a -> Maybe TimeZone
- parseDateTime :: Replace a => a -> Maybe UTCTime
- parseDateTime8601 :: Replace a => a -> Maybe UTCTime
- parseDateTimeCLF :: Replace a => a -> Maybe UTCTime
- parseShortMonth :: Replace a => a -> Maybe Int
- shortMonthArray :: Array Int Text
- type IPV4Address = (Word8, Word8, Word8, Word8)
- parseIPv4Address :: Replace a => a -> Maybe IPV4Address
- data Severity
- parseSeverity :: Replace a => a -> Maybe Severity
- severityKeywords :: Severity -> (Text, [Text])
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
MacroDescriptor | |
|
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
data WithCaptures Source #
do we need the captures in the RE or whould they be stripped out where possible
InclCaptures | include all captures |
ExclCaptures | remove captures where possible |
presentRegexType :: RegexType -> String Source #
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
runTests :: (Eq a, Show a) => RegexType -> (String -> Maybe a) -> [(String, a)] -> MacroEnv -> MacroID -> MacroDescriptor -> MacroDescriptor Source #
runTests' :: (Eq a, Show a) => RegexType -> (Match String -> Maybe a) -> [(String, a)] -> MacroEnv -> MacroID -> MacroDescriptor -> MacroDescriptor Source #
Parsing
parseIPv4Address :: Replace a => a -> Maybe IPV4Address Source #