Expand description
Pattern
s are one of the more powerful ways to query text inside Harper, especially for beginners.
Through the PatternLinter
trait, they make it much easier to
build Harper rules.
See the page about SequencePattern
for a concrete example of their use.
Structs§
- All
- A
Pattern
that consumes a list of other patterns and only matches if all the child patterns do. - AnyPattern
- Matches any single token.
- Either
Pattern - A pattern that returns the value of the longest match in a list.
- Fixed
Phrase - Matches a fixed sequence of tokens as they appear in the input. Case-insensitive for words but maintains exact matching for other token types.
- Implies
Quantity - This struct does two things.
- Indefinite
Article - Inflection
OfBe - Matches any inflection of the verb “be”:
am
,is
,are
,was
,were
,be
,been
,being
. - Invert
- A struct that matches any pattern except the one provided.
- Mergeable
Words - A
Pattern
that identifies adjacent words that could potentially be merged into a single word. - Naive
Pattern Group - A naive pattern collection that naively iterates through a list of patterns, returning the first one that matches.
- Nominal
Phrase - Pattern
Map - A map from
Pattern
to arbitrary data. - Repeating
Pattern - A pattern that will match one or more repetitions of the same pattern.
- Sequence
Pattern - A pattern that checks that a sequence of other patterns match.
There are specific extension methods available, but you can also use
Self::then
to add arbitrary patterns. - Similar
ToPhrase - Spelled
Number Pattern - Matches spelled-out numbers from one to ninety-nine
- Whitespace
Pattern - Word
- Matches a predefined word.
- Word
Pattern Group - A pattern collection to look for patterns that start with a specific word.
- WordSet
- A
super::Pattern
that matches against any of a set of provided words. For small sets of short words, it doesn’t allocate.
Traits§
- DocPattern
- Owned
Pattern Ext - Pattern
- Pattern
Ext - Single
Token Pattern - A simpler version of the
Pattern
trait that only matches a single token.