A library to defines a structure of regular expressions and a simple match operation for regular expressions. This library is used to translate integrated code in the form of POSIX extended regular expressions into Curry programs. It is based on the bachelor thesis "Foreign Code Integration in Curry" of Jasper Sikorra (March 2014).
Author: Corinna Wambsganz
Version: October 2022
eps
:: [Int] -> [ORegExp a]
ε |
literal
:: [Int] -> a -> [ORegExp a]
a |
alt
:: [Int] -> [ORegExp a] -> [ORegExp a] -> [ORegExp a]
α|β |
conc
:: [Int] -> [ORegExp a] -> [ORegExp a] -> [ORegExp a]
αβ |
rep
:: [Int] -> [ORegExp a] -> [ORegExp a]
α* |
pl
:: [Int] -> [ORegExp a] -> [ORegExp a]
α⁺ |
anyL
:: [Int] -> [ORegExp a]
_ |
bracket
:: [Int] -> [Either a (a,a)] -> [ORegExp a]
[as] |
negBracket
:: [Int] -> [Either a (a,a)] -> [ORegExp a]
[^as] |
start
:: [Int] -> [ORegExp a] -> Bool -> [ORegExp a]
^α |
end
:: [Int] -> [ORegExp a] -> Bool -> [ORegExp a]
α$ |
times
:: [Int] -> Int -> Int -> [ORegExp a] -> [ORegExp a]
α{n,m} |
captureG
:: Int -> [ORegExp a] -> [ORegExp a]
/(α)/ |
grepPos
:: (Data a, Ord a) => [ORegExp a] -> [a] -> Int
The operation grepPos
returns the first starting position of a substring
which matches the regular expression.
|
grep
:: (Data a, Ord a) => [ORegExp a] -> [a] -> [Int]
The operation grep
returns a list with starting positions of substrings
that match the regular expression.
|
grepShow
:: (Data a, Ord a) => [ORegExp a] -> [a] -> [[a]]
The operation grepShow
returns a list of substrings that match the regular
expression.
|
grepShowUnique
:: (Data a, Ord a) => [ORegExp a] -> [a] -> [[a]]
As grepShow
but without duplicated elements.
|
match
:: (Data a, Ord a) => [ORegExp a] -> [a] -> Bool
The match function is used to match lists with regular expressions |
capture
:: (Data a, Ord a) => [ORegExp a] -> [a] -> [(Int,[[a]])]
The operation capture
is used to return capture groups.
|
Data type for regex representation in Curry.
Type synonym: RegExp a = [ORegExp a]
Constructors:
Nil
:: ORegExp a
Literal
:: a -> ORegExp a
Xor
:: (RegExp a) -> (RegExp a) -> ORegExp a
Star
:: (RegExp a) -> ORegExp a
Plus
:: (RegExp a) -> ORegExp a
AnyLiteral
:: ORegExp a
Bracket
:: [Either a (a,a)] -> ORegExp a
NegBracket
:: [Either a (a,a)] -> ORegExp a
Start
:: (RegExp a) -> ORegExp a
End
:: (RegExp a) -> ORegExp a
Times
:: (Int,Int) -> (RegExp a) -> ORegExp a
Capture
:: Int -> (RegExp a) -> ORegExp a
a
|
α|β
|
αβ
|
α*
|
α⁺
|
_
|
[as]
|
[^as]
|
^α
|
α$
|
α{n,m}
|
/(α)/
|
The operation
|
The operation
|
The operation
|
As |