Struct SequenceExpr

Source
pub struct SequenceExpr { /* private fields */ }

Implementations§

Source§

impl SequenceExpr

Source

pub fn then(self, expr: impl Expr + 'static) -> Self

Push an expression to the operation list.

Source

pub fn then_optional(self, expr: impl Expr + 'static) -> Self

Pushes an expression that could move the cursor to the sequence, but does not require it.

Source

pub fn then_seq(self, other: Self) -> Self

Appends the steps in other onto the end of self. This is more efficient than Self::then because it avoids pointer redirection.

Source

pub fn then_indefinite_article(self) -> Self

Push an IndefiniteArticle to the end of the operation list.

Source

pub fn then_exact_word(self, word: &'static str) -> Self

Match examples of word case-sensitively.

Source

pub fn aco(word: &'static str) -> Self

Source

pub fn any_capitalization_of(word: &'static str) -> Self

Construct a new sequence with a Word at the beginning of the operation list.

Source

pub fn t_aco(self, word: &'static str) -> Self

Source

pub fn then_any_capitalization_of(self, word: &'static str) -> Self

Match examples of word that have any capitalization.

Source

pub fn then_any_word(self) -> Self

Matches any word.

Source

pub fn then_strict(self, kind: TokenKind) -> Self

Matches any token whose Kind exactly matches.

Source

pub fn t_ws(self) -> Self

Shorthand for Self::then_whitespace.

Source

pub fn then_whitespace(self) -> Self

Match against one or more whitespace tokens.

Source

pub fn then_one_or_more(self, expr: impl Expr + 'static) -> Self

Source

pub fn then_unless(self, condition: impl Expr + 'static) -> Self

Create a new condition that will step one token forward if met. If the condition is not met, the whole expression returns None.

This can be used to build out exceptions to other rules.

See UnlessStep for more info.

Source

pub fn t_any(self) -> Self

Match any single token.

Shorthand for Self::then_anything.

Source

pub fn then_anything(self) -> Self

Match any single token.

See AnyPattern for more info.

Source

pub fn then_nominal(self) -> Self

Adds a step matching a token where TokenKind::is_nominal() returns true.

Source

pub fn then_one_or_more_nominals(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_nominal() returns true.

Source

pub fn then_anything_but_nominal(self) -> Self

Adds a step matching a token where TokenKind::is_nominal() returns false.

Source

pub fn then_noun(self) -> Self

Adds a step matching a token where TokenKind::is_noun() returns true.

Source

pub fn then_one_or_more_nouns(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_noun() returns true.

Source

pub fn then_anything_but_noun(self) -> Self

Adds a step matching a token where TokenKind::is_noun() returns false.

Source

pub fn then_possessive_nominal(self) -> Self

Adds a step matching a token where TokenKind::is_possessive_nominal() returns true.

Source

pub fn then_one_or_more_possessive_nominals(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_possessive_nominal() returns true.

Source

pub fn then_anything_but_possessive_nominal(self) -> Self

Adds a step matching a token where TokenKind::is_possessive_nominal() returns false.

Source

pub fn then_plural_nominal(self) -> Self

Adds a step matching a token where TokenKind::is_plural_nominal() returns true.

Source

pub fn then_one_or_more_plural_nominals(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_plural_nominal() returns true.

Source

pub fn then_anything_but_plural_nominal(self) -> Self

Adds a step matching a token where TokenKind::is_plural_nominal() returns false.

Source

pub fn then_verb(self) -> Self

Adds a step matching a token where TokenKind::is_verb() returns true.

Source

pub fn then_one_or_more_verbs(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_verb() returns true.

Source

pub fn then_anything_but_verb(self) -> Self

Adds a step matching a token where TokenKind::is_verb() returns false.

Source

pub fn then_auxiliary_verb(self) -> Self

Adds a step matching a token where TokenKind::is_auxiliary_verb() returns true.

Source

pub fn then_one_or_more_auxiliary_verbs(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_auxiliary_verb() returns true.

Source

pub fn then_anything_but_auxiliary_verb(self) -> Self

Adds a step matching a token where TokenKind::is_auxiliary_verb() returns false.

Source

pub fn then_linking_verb(self) -> Self

Adds a step matching a token where TokenKind::is_linking_verb() returns true.

Source

pub fn then_one_or_more_linking_verbs(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_linking_verb() returns true.

Source

pub fn then_anything_but_linking_verb(self) -> Self

Adds a step matching a token where TokenKind::is_linking_verb() returns false.

Source

pub fn then_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_pronoun() returns true.

Source

pub fn then_one_or_more_pronouns(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_pronoun() returns true.

Source

pub fn then_anything_but_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_pronoun() returns false.

Source

pub fn then_punctuation(self) -> Self

Adds a step matching a token where TokenKind::is_punctuation() returns true.

Source

pub fn then_one_or_more_punctuations(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_punctuation() returns true.

Source

pub fn then_anything_but_punctuation(self) -> Self

Adds a step matching a token where TokenKind::is_punctuation() returns false.

Source

pub fn then_conjunction(self) -> Self

Adds a step matching a token where TokenKind::is_conjunction() returns true.

Source

pub fn then_one_or_more_conjunctions(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_conjunction() returns true.

Source

pub fn then_anything_but_conjunction(self) -> Self

Adds a step matching a token where TokenKind::is_conjunction() returns false.

Source

pub fn then_comma(self) -> Self

Adds a step matching a token where TokenKind::is_comma() returns true.

Source

pub fn then_one_or_more_commas(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_comma() returns true.

Source

pub fn then_anything_but_comma(self) -> Self

Adds a step matching a token where TokenKind::is_comma() returns false.

Source

pub fn then_period(self) -> Self

Adds a step matching a token where TokenKind::is_period() returns true.

Source

pub fn then_one_or_more_periods(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_period() returns true.

Source

pub fn then_anything_but_period(self) -> Self

Adds a step matching a token where TokenKind::is_period() returns false.

Source

pub fn then_number(self) -> Self

Adds a step matching a token where TokenKind::is_number() returns true.

Source

pub fn then_one_or_more_numbers(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_number() returns true.

Source

pub fn then_anything_but_number(self) -> Self

Adds a step matching a token where TokenKind::is_number() returns false.

Source

pub fn then_case_separator(self) -> Self

Adds a step matching a token where TokenKind::is_case_separator() returns true.

Source

pub fn then_one_or_more_case_separators(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_case_separator() returns true.

Source

pub fn then_anything_but_case_separator(self) -> Self

Adds a step matching a token where TokenKind::is_case_separator() returns false.

Source

pub fn then_adverb(self) -> Self

Adds a step matching a token where TokenKind::is_adverb() returns true.

Source

pub fn then_one_or_more_adverbs(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_adverb() returns true.

Source

pub fn then_anything_but_adverb(self) -> Self

Adds a step matching a token where TokenKind::is_adverb() returns false.

Source

pub fn then_adjective(self) -> Self

Adds a step matching a token where TokenKind::is_adjective() returns true.

Source

pub fn then_one_or_more_adjectives(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_adjective() returns true.

Source

pub fn then_anything_but_adjective(self) -> Self

Adds a step matching a token where TokenKind::is_adjective() returns false.

Source

pub fn then_apostrophe(self) -> Self

Adds a step matching a token where TokenKind::is_apostrophe() returns true.

Source

pub fn then_one_or_more_apostrophes(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_apostrophe() returns true.

Source

pub fn then_anything_but_apostrophe(self) -> Self

Adds a step matching a token where TokenKind::is_apostrophe() returns false.

Source

pub fn then_hyphen(self) -> Self

Adds a step matching a token where TokenKind::is_hyphen() returns true.

Source

pub fn then_one_or_more_hyphens(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_hyphen() returns true.

Source

pub fn then_anything_but_hyphen(self) -> Self

Adds a step matching a token where TokenKind::is_hyphen() returns false.

Source

pub fn then_determiner(self) -> Self

Adds a step matching a token where TokenKind::is_determiner() returns true.

Source

pub fn then_one_or_more_determiners(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_determiner() returns true.

Source

pub fn then_anything_but_determiner(self) -> Self

Adds a step matching a token where TokenKind::is_determiner() returns false.

Source

pub fn then_proper_noun(self) -> Self

Adds a step matching a token where TokenKind::is_proper_noun() returns true.

Source

pub fn then_one_or_more_proper_nouns(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_proper_noun() returns true.

Source

pub fn then_anything_but_proper_noun(self) -> Self

Adds a step matching a token where TokenKind::is_proper_noun() returns false.

Source

pub fn then_preposition(self) -> Self

Adds a step matching a token where TokenKind::is_preposition() returns true.

Source

pub fn then_one_or_more_prepositions(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_preposition() returns true.

Source

pub fn then_anything_but_preposition(self) -> Self

Adds a step matching a token where TokenKind::is_preposition() returns false.

Source

pub fn then_third_person_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_third_person_pronoun() returns true.

Source

pub fn then_one_or_more_third_person_pronouns(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_third_person_pronoun() returns true.

Source

pub fn then_anything_but_third_person_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_third_person_pronoun() returns false.

Source

pub fn then_third_person_singular_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_third_person_singular_pronoun() returns true.

Source

pub fn then_one_or_more_third_person_singular_pronouns(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_third_person_singular_pronoun() returns true.

Source

pub fn then_anything_but_third_person_singular_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_third_person_singular_pronoun() returns false.

Source

pub fn then_third_person_plural_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_third_person_plural_pronoun() returns true.

Source

pub fn then_one_or_more_third_person_plural_pronouns(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_third_person_plural_pronoun() returns true.

Source

pub fn then_anything_but_third_person_plural_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_third_person_plural_pronoun() returns false.

Source

pub fn then_first_person_singular_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_first_person_singular_pronoun() returns true.

Source

pub fn then_one_or_more_first_person_singular_pronouns(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_first_person_singular_pronoun() returns true.

Source

pub fn then_anything_but_first_person_singular_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_first_person_singular_pronoun() returns false.

Source

pub fn then_first_person_plural_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_first_person_plural_pronoun() returns true.

Source

pub fn then_one_or_more_first_person_plural_pronouns(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_first_person_plural_pronoun() returns true.

Source

pub fn then_anything_but_first_person_plural_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_first_person_plural_pronoun() returns false.

Source

pub fn then_second_person_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_second_person_pronoun() returns true.

Source

pub fn then_one_or_more_second_person_pronouns(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_second_person_pronoun() returns true.

Source

pub fn then_anything_but_second_person_pronoun(self) -> Self

Adds a step matching a token where TokenKind::is_second_person_pronoun() returns false.

Source

pub fn then_non_plural_nominal(self) -> Self

Adds a step matching a token where TokenKind::is_non_plural_nominal() returns true.

Source

pub fn then_one_or_more_non_plural_nominals(self) -> Self

Adds a step matching one or more consecutive tokens where TokenKind::is_non_plural_nominal() returns true.

Source

pub fn then_anything_but_non_plural_nominal(self) -> Self

Adds a step matching a token where TokenKind::is_non_plural_nominal() returns false.

Trait Implementations§

Source§

impl Default for SequenceExpr

Source§

fn default() -> SequenceExpr

Returns the “default value” for a type. Read more
Source§

impl Expr for SequenceExpr

Source§

fn run(&self, cursor: usize, tokens: &[Token], source: &[char]) -> Option<Span>

Run the expression starting at an index, returning the total matched window.

If any step returns None, the entire expression does as well.

Source§

impl<S> From<S> for SequenceExpr
where S: Step + 'static,

Source§

fn from(step: S) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<E> ExprExt for E
where E: Expr + ?Sized,

Source§

fn iter_matches<'a>( &'a self, tokens: &'a [Token], source: &'a [char], ) -> Box<dyn Iterator<Item = Span> + 'a>

Iterate over all matches of this expression in the document, automatically filtering out overlapping matches, preferring the first.
Source§

fn iter_matches_in_doc<'a>( &'a self, doc: &'a Document, ) -> Box<dyn Iterator<Item = Span> + 'a>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<E> OwnedExprExt for E
where E: Expr + 'static,

Source§

fn or(self, other: impl Expr + 'static) -> LongestMatchOf

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> LSend for T
where T: ?Sized,