Safe Haskell | None |
---|---|
Language | Haskell2010 |
Text.Regex.TDFA.Pattern
Description
This Text.Regex.TDFA.Pattern module provides the Pattern
data
type and its subtypes. This Pattern
type is used to represent
the parsed form of a regular expression.
Synopsis
- data Pattern
- = PEmpty
- | PGroup (Maybe GroupIndex) Pattern
- | POr [Pattern]
- | PConcat [Pattern]
- | PQuest Pattern
- | PPlus Pattern
- | PStar Bool Pattern
- | PBound Int (Maybe Int) Pattern
- | PCarat { }
- | PDollar { }
- | PDot { }
- | PAny { }
- | PAnyNot { }
- | PEscape {
- getDoPa :: DoPa
- getPatternChar :: Char
- | PChar {
- getDoPa :: DoPa
- getPatternChar :: Char
- | PNonCapture Pattern
- | PNonEmpty Pattern
- data PatternSet = PatternSet (Maybe (Set Char)) (Maybe (Set PatternSetCharacterClass)) (Maybe (Set PatternSetCollatingElement)) (Maybe (Set PatternSetEquivalenceClass))
- newtype PatternSetCharacterClass = PatternSetCharacterClass {}
- newtype PatternSetCollatingElement = PatternSetCollatingElement {}
- newtype PatternSetEquivalenceClass = PatternSetEquivalenceClass {}
- type GroupIndex = Int
- newtype DoPa = DoPa {}
- decodeCharacterClass :: PatternSetCharacterClass -> String
- decodePatternSet :: PatternSet -> Set Char
- showPattern :: Pattern -> String
- starTrans :: Pattern -> Pattern
- starTrans' :: Pattern -> Pattern
- simplify' :: Pattern -> Pattern
- dfsPattern :: (Pattern -> Pattern) -> Pattern -> Pattern
Documentation
Pattern
is the type returned by the regular expression parser parseRegex
.
This is consumed by the Text.Regex.TDFA.CorePattern module and the tender leaves
are nibbled by the Text.Regex.TDFA.TNFA module.
The DoPa
field is the index of the component in the regex string r
.
Constructors
PEmpty |
|
PGroup (Maybe GroupIndex) Pattern | Group |
POr [Pattern] | Alternative |
PConcat [Pattern] | Sequence |
PQuest Pattern | Zero or one repetitions |
PPlus Pattern | One or more repetitions |
PStar Bool Pattern | Zero or more repetitions |
PBound Int (Maybe Int) Pattern | Given number or repetitions |
PCarat |
|
PDollar |
|
PDot |
|
PAny | Bracket expression |
Fields
| |
PAnyNot | Inverted bracket expression |
Fields
| |
PEscape | Backslashed character |
Fields
| |
PChar | Single character, matches given character. |
Fields
| |
PNonCapture Pattern | Tag for internal use, introduced by |
PNonEmpty Pattern | Tag for internal use, introduced by |
data PatternSet #
Content of a bracket expression [...]
organized into
characters,
POSIX character classes (e.g. [[:alnum:]]
),
collating elements (e.g. [.ch.]
, unused), and
equivalence classes (e.g. [=a=]
, treated as characters).
Constructors
PatternSet (Maybe (Set Char)) (Maybe (Set PatternSetCharacterClass)) (Maybe (Set PatternSetCollatingElement)) (Maybe (Set PatternSetEquivalenceClass)) |
Instances
Show PatternSet # | Hand-rolled implementation, giving textual rather than Haskell representation. |
Defined in Text.Regex.TDFA.Pattern Methods showsPrec :: Int -> PatternSet -> ShowS # show :: PatternSet -> String # showList :: [PatternSet] -> ShowS # | |
Eq PatternSet # | |
Defined in Text.Regex.TDFA.Pattern |
newtype PatternSetCharacterClass #
Content of [: :]
, e.g. "alnum"
for [:alnum:]
.
Constructors
PatternSetCharacterClass | |
Instances
newtype PatternSetCollatingElement #
Content of [. .]
, e.g. "ch"
for [.ch.]
.
Constructors
PatternSetCollatingElement | |
Instances
newtype PatternSetEquivalenceClass #
Content of [= =]
, e.g. "a"
for [=a=]
.
Constructors
PatternSetEquivalenceClass | |
Instances
type GroupIndex = Int #
GroupIndex
is for indexing submatches from capturing parenthesized groups (PGroup
or Group
).
Used to track elements of the pattern that accept characters or are anchors.
decodeCharacterClass :: PatternSetCharacterClass -> String #
This returns the strictly ascending list of characters
represented by [: :]
POSIX character classes.
Unrecognized class names return an empty string.
Since: 1.3.2
decodePatternSet :: PatternSet -> Set Char #
decodePatternSet
cannot handle collating element and treats
equivalence classes as just their definition and nothing more.
Since: 1.3.2
showPattern :: Pattern -> String #
Internal use
starTrans :: Pattern -> Pattern #
Do the transformation and simplification in a single traversal.
This removes the PPlus
, PQuest
, and PBound
values, changing to POr
and PEmpty
and PStar
. For some PBound
values it adds
PNonEmpty
and PNonCapture
semantic marker. It also simplifies to
flatten out nested POr
and PConcat
instances and eliminate some
unneeded PEmpty
values.
Internal use, operations to support debugging under ghci
starTrans' :: Pattern -> Pattern #