HaLeX-1.1: HaLeX enables modelling, manipulation and animation of regular languagesSource codeContentsIndex
Language.HaLex.RegExp
Portabilityportable
Stabilityprovisional
Maintainerjas@di.uminho.pt
Contents
Data type with recursion pattern
Matching
Size
Printing
Simplification
Normalization
Description

Regular Expressions in Haskell.

Code Included in the Lecture Notes on Language Processing (with a functional flavour).

Synopsis
data RegExp sy
= Empty
| Epsilon
| Literal sy
| Or (RegExp sy) (RegExp sy)
| Then (RegExp sy) (RegExp sy)
| Star (RegExp sy)
| OneOrMore (RegExp sy)
| Optional (RegExp sy)
cataRegExp :: (re, re, re -> re -> re, re -> re, sy -> re, re -> re -> re, re -> re, re -> re) -> RegExp sy -> re
matchesRE :: Eq sy => RegExp sy -> [sy] -> Bool
matches' :: Eq sy => RegExp sy -> [sy] -> Bool
sizeRegExp :: RegExp sy -> Int
showRE :: Show sy => RegExp sy -> [Char]
simplifyRegExp :: Eq sy => RegExp sy -> RegExp sy
extREtoRE :: RegExp sy -> RegExp sy
Data type with recursion pattern
data RegExp sy Source
Type of regular expressions.
Constructors
EmptyEmpty Language
EpsilonEmpty String
Literal syLiterals
Or (RegExp sy) (RegExp sy)Disjuncion
Then (RegExp sy) (RegExp sy)Sequence
Star (RegExp sy)Repetition, possibly zero time
OneOrMore (RegExp sy)One or more times (extended RegExp)
Optional (RegExp sy)Optional (extended RegExp)
show/hide Instances
Eq sy => Eq (RegExp sy)
Read sy => Read (RegExp sy)
Show sy => Show (RegExp sy)
cataRegExp :: (re, re, re -> re -> re, re -> re, sy -> re, re -> re -> re, re -> re, re -> re) -> RegExp sy -> reSource
Catamorphism induced by the RegExp inductive data type
Matching
matchesRESource
:: Eq sy
=> RegExp sy(canonical) Regular Expression
-> [sy]Input Symbols
-> Bool
Test whether a match can be found for the given regular expression in the given sequence of characters. The regular expression is assumed not to contain OneOrMore or Optional. See also matches'.
matches'Source
:: Eq sy
=> RegExp syRegular Expression
-> [sy]Input Symbols
-> Bool
Test whether a match can be found for the given regular expression in the given sequence of characters. The regular expression is allowed to contain OneOrMore or Optional.
Size
sizeRegExpSource
::
=> RegExp syRegular Expression
-> IntSize
Compute the size of a regular expression. We define the size of a regular expression as the number of occurrences of symbols of the alfabeth
Printing
showRESource
:: Show sy
=> RegExp syRegular Expression
-> [Char]String-based Regular Expression

Print regular expression to String as a catamorphism. A straightforward (catamorphic) show function.

(it produces too many brackets, making it difficult to read or understand the expression)

Simplification
simplifyRegExp :: Eq sy => RegExp sy -> RegExp sySource
Simplify regular expressions according to the algebra of regular expressions.
Normalization
extREtoRE :: RegExp sy -> RegExp sySource
Rewrite extended regular expressions to plain regular expression. This means that the OneOrMore and Optional constructors are normalized away.
Produced by Haddock version 2.3.0