Expand description
An Expr
is a declarative way to express whether a certain set of tokens fulfill a criteria.
For example, if we want to look for the word “that” followed by an adjective, we could build an expression to do so.
The actual searching is done by another system (usually a part of the lint framework). It iterates through a document, checking if each index matches the criteria.
When supplied a specific position in a token stream, the technical job of an Expr
is to determine the window of tokens (including the cursor itself) that fulfills whatever criteria the author desires.
The goal of the Expr
initiative is to make rules easier to read as well as to write.
Gone are the days of trying to manually parse the logic of another man’s Rust code.
See also: SequenceExpr
.
Structs§
- All
- An
Expr
that matches against tokens if and only if all of its children do. This can be useful for situations where you have multiple expressions that represent a grammatical error, but you need all of them to match to be certain. - Anchor
End - A
Step
which will match only if the cursor is over the last non-whitespace character in stream. It will return that token. - Anchor
Start - A
Step
which will match only if the cursor is over the first word-like of a token stream. It will return that token. - Duration
Expr - ExprMap
- A map from an
Expr
to arbitrary data. - First
Match Of - A naive expr collection that naively iterates through a list of patterns, returning the first one that matches.
- 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.
- Longest
Match Of - An
Expr
that returns the farthest offset of the longest match in a list of expressions. - Mergeable
Words - A
Expr
that identifies adjacent words that could potentially be merged into a single word. - Optional
- An optional expression.
Forces the optional expression to always return Some by transmuting
None
intoSome(cursor..cursor)
. - Reflexive
Pronoun - Matches reflexive pronouns with configurable strictness.
- Repeating
- An expression that will match one or more repetitions of the same expression.
- Sequence
Expr - Similar
ToPhrase - Space
OrHyphen - Matches either a space or a hyphen, useful for matching compound words.
- Spelled
Number Expr - Matches spelled-out numbers from one to ninety-nine
- Time
Unit Expr - Matches a time unit.
- Unless
Step - Provides the ability to use an expression as a condition. If the condition does not match, it will return the result of the provided step.
- Word
Expr Group - An expression collection to look for expressions that start with a specific word.
Traits§
- Expr
- ExprExt
- Owned
Expr Ext - Step
- An atomic step within a larger expression.