HaLeX-1.2.6: HaLeX enables modelling, manipulation and visualization of regular languages

Copyright(c) João Saraiva 20012002200320042005 2016
LicenseLGPL
Maintainerjas@di.uminho.pt
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

Language.HaLex.RegExp

Contents

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 Source #

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)

RESet [sy]

Set (extended RegExp)

Instances

Eq sy => Eq (RegExp sy) Source # 

Methods

(==) :: RegExp sy -> RegExp sy -> Bool #

(/=) :: RegExp sy -> RegExp sy -> Bool #

Read sy => Read (RegExp sy) Source # 
Show sy => Show (RegExp sy) Source #

Pretty print of regular expressions.

Methods

showsPrec :: Int -> RegExp sy -> ShowS #

show :: RegExp sy -> String #

showList :: [RegExp sy] -> ShowS #

cataRegExp :: (re, re, re -> re -> re, re -> re, sy -> re, re -> re -> re, re -> re, re -> re, [sy] -> re) -> RegExp sy -> re Source #

Catamorphism induced by the RegExp inductive data type

Matching

matchesRE Source #

Arguments

:: 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 #

Arguments

:: 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 Source #

Arguments

:: 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

Printing

showRE Source #

Arguments

:: 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 Source #

Simplify regular expressions according to the algebra of regular expressions.

Normalization

extREtoRE :: RegExp sy -> RegExp sy Source #

Rewrite extended regular expressions to plain regular expression. This means that the OneOrMore Optional and RESet constructors are normalized away.