Module RegExpEff

An efficient library that defines a structure of regular expressions and some operations for regular expressions. This library is used to translate integrated code in the form of POSIX extended regular expressions into efficient Curry programs. The implementation is based on the paper "A Play on Regular Expressions - Functional Pearl" by Fischer, Huch and Wilke (September 27–29, 2010, Baltimore, Maryland, USA).

Author: Corinna Wambsganz

Version: October 2022

Summary of exported operations:

eps :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b  Deterministic 
literal :: (Eq a, CGFunction a, Semiringc a) => [Int] -> Char -> Reg (Int,Char) a  Deterministic 
alt :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b -> Reg a b -> Reg a b  Deterministic 
conc :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b -> Reg a b -> Reg a b  Deterministic 
rep :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b -> Reg a b  Deterministic 
pl :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b -> Reg a b  Deterministic 
anyL :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b  Deterministic 
bracket :: (Eq a, CGFunction a, Semiringc a) => [Int] -> [Either Char (Char,Char)] -> Reg (Int,Char) a  Deterministic 
negBracket :: (Eq a, CGFunction a, Semiringc a) => [Int] -> [Either Char (Char,Char)] -> Reg (Int,Char) a  Deterministic 
start :: (Eq a, CGFunction a, Semiringc a) => [Int] -> Reg (Int,Char) a -> Bool -> Reg (Int,Char) a  Deterministic 
end :: (Eq a, CGFunction a, Semiringc a) => [Int] -> Reg (Int,Char) a -> Bool -> Reg (Int,Char) a  Deterministic 
times :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Int -> Int -> Reg a b -> Reg a b  Deterministic 
captureG :: (Ord a, Eq b, CGFunction b, Semiring b) => Int -> Reg a b -> Reg a b  Deterministic 
grep :: Ord a => Reg (Int,a) All -> [a] -> [Int]  Deterministic 
The grep function returns efficient a list with startingpositions of substrings that match the regular expression.
grepPos :: Ord a => Reg (Int,a) All -> [a] -> Int  Deterministic 
The grepPos function returns efficient the first startingposition of a substring which matches the regular expression.
grepShow :: Ord a => Reg (Int,a) AllRange -> [a] -> [[a]]  Deterministic 
The grepShow function returns efficient a list of substrings that match the regular expression.
grepShowUnique :: Ord a => Reg (Int,a) AllRange -> [a] -> [[a]]  Deterministic 
capture :: Ord a => Reg (Int,a) CaptureGroups -> [a] -> [(Int,[[a]])]  Deterministic 
The capture function is used to return capture groups efficient.
match :: Ord a => Reg (Int,a) CaptureGroups -> [a] -> Bool  Deterministic 

Exported datatypes:


Reg

Constructors:


Exported operations:

eps :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b  Deterministic 

literal :: (Eq a, CGFunction a, Semiringc a) => [Int] -> Char -> Reg (Int,Char) a  Deterministic 

alt :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b -> Reg a b -> Reg a b  Deterministic 

conc :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b -> Reg a b -> Reg a b  Deterministic 

rep :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b -> Reg a b  Deterministic 

pl :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b -> Reg a b  Deterministic 

anyL :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Reg a b  Deterministic 

bracket :: (Eq a, CGFunction a, Semiringc a) => [Int] -> [Either Char (Char,Char)] -> Reg (Int,Char) a  Deterministic 

negBracket :: (Eq a, CGFunction a, Semiringc a) => [Int] -> [Either Char (Char,Char)] -> Reg (Int,Char) a  Deterministic 

start :: (Eq a, CGFunction a, Semiringc a) => [Int] -> Reg (Int,Char) a -> Bool -> Reg (Int,Char) a  Deterministic 

end :: (Eq a, CGFunction a, Semiringc a) => [Int] -> Reg (Int,Char) a -> Bool -> Reg (Int,Char) a  Deterministic 

times :: (Ord a, Eq b, CGFunction b, Semiring b) => [Int] -> Int -> Int -> Reg a b -> Reg a b  Deterministic 

captureG :: (Ord a, Eq b, CGFunction b, Semiring b) => Int -> Reg a b -> Reg a b  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

grep :: Ord a => Reg (Int,a) All -> [a] -> [Int]  Deterministic 

The grep function returns efficient a list with startingpositions of substrings that match the regular expression.

Example call:
(grep r s)
Parameters:
  • r : The regular expression
  • s : The input list

grepPos :: Ord a => Reg (Int,a) All -> [a] -> Int  Deterministic 

The grepPos function returns efficient the first startingposition of a substring which matches the regular expression.

Example call:
(grepPos r s)
Parameters:
  • r : The regular expression
  • s : The input list

grepShow :: Ord a => Reg (Int,a) AllRange -> [a] -> [[a]]  Deterministic 

The grepShow function returns efficient a list of substrings that match the regular expression.

Example call:
(grepShow r s)
Parameters:
  • r : The regular expression
  • s : The input list
Returns:
l - The list of substrings from s that match r

grepShowUnique :: Ord a => Reg (Int,a) AllRange -> [a] -> [[a]]  Deterministic 

capture :: Ord a => Reg (Int,a) CaptureGroups -> [a] -> [(Int,[[a]])]  Deterministic 

The capture function is used to return capture groups efficient.

Example call:
(capture r s)
Parameters:
  • r : The regular expression
  • s : The input list

match :: Ord a => Reg (Int,a) CaptureGroups -> [a] -> Bool  Deterministic