Module expr

Module expr 

Source
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.
AnchorEnd
A Step which will match only if the cursor is over the last non-whitespace character in stream. It will return that token.
AnchorStart
A Step which will match only if the cursor is over the first word-like of a token stream. It will return that token.
DurationExpr
ExprMap
A map from an Expr to arbitrary data.
FirstMatchOf
A naive expr collection that naively iterates through a list of patterns, returning the first one that matches.
FixedPhrase
Matches a fixed sequence of tokens as they appear in the input. Case-insensitive for words but maintains exact matching for other token types.
LongestMatchOf
An Expr that returns the farthest offset of the longest match in a list of expressions.
MergeableWords
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 into Some(cursor..cursor).
ReflexivePronoun
Matches reflexive pronouns with configurable strictness.
Repeating
An expression that will match one or more repetitions of the same expression.
SequenceExpr
SimilarToPhrase
SpaceOrHyphen
Matches either a space or a hyphen, useful for matching compound words.
SpelledNumberExpr
Matches spelled-out numbers from one to ninety-nine
TimeUnitExpr
Matches a time unit.
UnlessStep
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.
WordExprGroup
An expression collection to look for expressions that start with a specific word.

Traits§

Expr
ExprExt
OwnedExprExt
Step
An atomic step within a larger expression.