UMinho Haskell Libraries (1.0)ContentsIndex
Language.HaLex.RegExp
Portability portable
Stability provisional
Maintainer jas@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
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)
Instances
Show sy => Show (RegExp sy)
(Read sy, ??? sy) => Read (RegExp sy)
(Eq sy, ??? sy) => Eq (RegExp sy)
cataRegExp :: (re, re, re -> re -> re, re -> re, sy -> re, re -> re -> re, re -> re, re -> re) -> RegExp sy -> re
Catamorphism induced by the RegExp inductive data type
Matching
matchesRE :: Eq sy => RegExp sy -> [sy] -> 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' :: Eq sy => RegExp sy -> [sy] -> 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
sizeRegExp :: RegExp sy -> Int
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
showRE :: Show sy => RegExp sy -> [Char]
Print regular expression to String as a catamorphism A straightforward (catamorphic) show function: it produces too many brackets, making it diffcicult to read or understand the expression.
Simplification
simplifyRegExp :: Eq sy => RegExp sy -> RegExp sy
Simplify regular expressions according to the algebra of regular expressions.
Normalization
extREtoRE :: RegExp sy -> RegExp sy
Rewrite extended regular expressions to plain regular expression. This means that the OneOrMore and Optional constructors are normalized away.
Produced by Haddock version 0.6