The CorePattern module deconstructs the Pattern tree created by ReadRegex.parseRegex and returns a simpler Q/P tree with annotations at each Q node. This will be converted by the TNFA module into a QNFA finite automata.
Of particular note, this Pattern to Q/P conversion creates and assigns all the internal Tags that will be used during the matching process, and associates the captures groups with the tags that represent their starting and ending locations and with their immediate parent group.
Each Maximize and Minimize tag is held as either a preTag or a postTag by one and only one location in the Q/P tree. The Orbit tags are each held by one and only one Star node. Tags that stop a Group are also held in perhaps numerous preReset lists.
The additional nullQ::nullView field of Q records the potentially complex information about what tests and tags must be used if the pattern unQ::P matches 0 zero characters. There can be redundancy in nullView, which is eliminated by cleanNullView.
Uses recursive do notation.
- data Q = Q {}
- data P
- data WhichTest
- data Wanted
- = WantsQNFA
- | WantsQT
- | WantsBoth
- | WantsEither
- type TestInfo = (WhichTest, DoPa)
- data OP
- newtype SetTestInfo = SetTestInfo {}
- type NullView = [(SetTestInfo, WinTags)]
- patternToQ :: CompOption -> (Pattern, (GroupIndex, DoPa)) -> (Q, Array Tag OP, Array GroupIndex [GroupInfo])
- cleanNullView :: NullView -> NullView
- cannotAccept :: Q -> Bool
- mustAccept :: Q -> Bool
Documentation
Known predicates, just Beginning of Line (^) and End of Line ($).
newtype SetTestInfo Source
type NullView = [(SetTestInfo, WinTags)]Source
patternToQ :: CompOption -> (Pattern, (GroupIndex, DoPa)) -> (Q, Array Tag OP, Array GroupIndex [GroupInfo])Source
cannotAccept :: Q -> BoolSource
mustAccept :: Q -> BoolSource