|
| Language.HaLex.RegExp | | Portability | portable | | Stability | provisional | | Maintainer | jas@di.uminho.pt |
|
|
|
|
|
| Description |
Regular Expressions in Haskell.
Code Included in the Lecture Notes on
Language Processing (with a functional flavour).
|
|
| Synopsis |
|
|
|
|
| Data type with recursion pattern |
|
| data RegExp sy |
| Type of regular expressions. | | Constructors | | Empty | Empty Language | | Epsilon | Empty String | | Literal sy | Literals | | 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 | (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' |
| :: Eq sy | | | => RegExp sy | 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
allowed to contain OneOrMore or Optional. |
|
|
| Size |
|
| sizeRegExp |
| :: RegExp sy | Regular Expression | | -> Int | Size | | 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 and epsilon symbols |
|
|
| Printing |
|
| showRE |
| :: Show sy | | | => RegExp sy | Regular 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 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 |