Safe Haskell | None |
---|---|
Language | Haskell2010 |
Tools to manipulate regular expressions.
Synopsis
- data Regex
- pattern REmpty :: Regex
- pattern RAlt :: Regex -> Regex -> Regex
- pattern RSeq :: Regex -> Regex -> Regex
- nullable :: Regex -> Bool
- class Satisfiable a where
- satisfiable :: a -> Bool
- data CharClass = CMinus {}
- pattern CEmpty :: CharClass
- pattern CC :: CharClassUnion -> CharClass
- data CharClassUnion
- = CAny
- | CAlt [CharClassAtom]
- pattern CCEmpty :: CharClassUnion
- data CharClassAtom
- rChar :: Char -> Regex
- rSeq :: Regex -> Regex -> Regex
- rSeqs :: [Regex] -> Regex
- rAlt :: Regex -> Regex -> Regex
- rAlts :: [Regex] -> Regex
- rMinus :: Regex -> Regex -> Regex
- rStar :: Regex -> Regex
- rPlus :: Regex -> Regex
- rOpt :: Regex -> Regex
- cAlt :: CharClass -> CharClass -> Regex
- cMinus :: CharClass -> CharClass -> Regex
- cChar :: Char -> CharClass
- cAlts :: [Char] -> CharClass
- cDigit :: CharClass
- cLower :: CharClass
- cUpper :: CharClass
- cLetter :: CharClass
- cAny :: CharClass
- cAtom :: CharClassAtom -> CharClass
- ccuMinus :: CharClassUnion -> CharClassUnion -> Either CharClass CharClassUnion
- onlyOneChar :: CharClassUnion -> Bool
- isEmpty :: CharClassUnion -> Bool
Regular expressions
Regular expressions are constructed over character classes.
Use smart constructors to ensure invariants.
RChar CharClass | Atomic regular expression. |
RAlts (List2 Regex) | Alternative/sum: List free of duplicates and |
RMinus Regex Regex | Difference. Most lexer generators do not support difference in general, only at the level of character classes. LBNF has general difference, so it is represented here. |
REps | Language of the empty word (empty sequence). |
RSeqs (List2 Regex) | Sequence/product. List free of |
RStar Regex | 0 or more repetitions.
|
RPlus Regex | 1 or more repetitions.
|
ROpt Regex | 0 or 1 repetitions.
|
Instances
Eq Regex Source # | |
Ord Regex Source # | |
Defined in BNFC.Types.Regex | |
Show Regex Source # | |
Satisfiable Regex Source # | |
Defined in BNFC.Types.Regex satisfiable :: Regex -> Bool Source # | |
ReifyRegex Regex Source # | |
Defined in BNFC.Check.Regex reifyRegex :: Regex -> Reg Source # | |
Print Regex Source # | |
Print Regex Source # | |
Print Regex Source # | |
nullable :: Regex -> Bool Source #
Check if a regular expression is nullable (accepts the empty string).
class Satisfiable a where Source #
Check if a regular expression matches at least one word.
For differences, this check may err on the positive side.
satisfiable :: a -> Bool Source #
Instances
Satisfiable CharClassUnion Source # | |
Defined in BNFC.Types.Regex satisfiable :: CharClassUnion -> Bool Source # | |
Satisfiable CharClass Source # | |
Defined in BNFC.Types.Regex satisfiable :: CharClass -> Bool Source # | |
Satisfiable Regex Source # | |
Defined in BNFC.Types.Regex satisfiable :: Regex -> Bool Source # |
Character classes
Character classes are regular expressions that recognize
character sequences of length exactly one. These are often
distinguished from arbitrary regular expressions in lexer
generators, e.g. in alex
.
We represent character classes as a difference of unions of atomic character classes.
Semantics: ⟦ CMinus ccYes ccNo ⟧ = ⟦ ccYes ⟧ ⟦ ccNo ⟧
CMinus | |
|
Instances
Eq CharClass Source # | |
Ord CharClass Source # | |
Defined in BNFC.Types.Regex | |
Show CharClass Source # | |
Satisfiable CharClass Source # | |
Defined in BNFC.Types.Regex satisfiable :: CharClass -> Bool Source # | |
ReifyRegex CharClass Source # | |
Defined in BNFC.Check.Regex reifyRegex :: CharClass -> Reg Source # |
pattern CC :: CharClassUnion -> CharClass Source #
data CharClassUnion Source #
Possibly overlapping union of character classes.
CAny | Any character, LBNF |
CAlt [CharClassAtom] | Any of the given (≥0) alternatives. List is free of duplicates. |
Instances
pattern CCEmpty :: CharClassUnion Source #
data CharClassAtom Source #
Atomic character class.
CChar Char | A single character. |
CDigit |
|
CLower | Lower case character, LBNF |
CUpper | Upper case character, LBNF |
Instances
Eq CharClassAtom Source # | |
Defined in BNFC.Types.Regex (==) :: CharClassAtom -> CharClassAtom -> Bool Source # (/=) :: CharClassAtom -> CharClassAtom -> Bool Source # | |
Ord CharClassAtom Source # | |
Defined in BNFC.Types.Regex compare :: CharClassAtom -> CharClassAtom -> Ordering Source # (<) :: CharClassAtom -> CharClassAtom -> Bool Source # (<=) :: CharClassAtom -> CharClassAtom -> Bool Source # (>) :: CharClassAtom -> CharClassAtom -> Bool Source # (>=) :: CharClassAtom -> CharClassAtom -> Bool Source # max :: CharClassAtom -> CharClassAtom -> CharClassAtom Source # min :: CharClassAtom -> CharClassAtom -> CharClassAtom Source # | |
Show CharClassAtom Source # | |
Defined in BNFC.Types.Regex | |
Print CharClassAtom Source # | |
Defined in BNFC.Backend.Txt2Tags.Txt2Tags | |
Print CharClassAtom Source # | |
Defined in BNFC.Backend.Latex.Latex | |
Print CharClassAtom Source # | |
Defined in BNFC.Backend.Haskell.Lexer |
Smart constructor for regular expressions.
Smart constructors for character classes.
cAtom :: CharClassAtom -> CharClass Source #
ccuMinus :: CharClassUnion -> CharClassUnion -> Either CharClass CharClassUnion Source #
Smart constructor for CharClass
from difference..
Mutually reduce: (A - B) = (A B) - (B A)
onlyOneChar :: CharClassUnion -> Bool Source #
isEmpty :: CharClassUnion -> Bool Source #