Enum rslint_regex::Node[][src]

pub enum Node {
    Empty,
    Disjunction(SpanVec<Node>),
    Assertion(SpanAssertionKind),
    Alternative(SpanVec<Node>),
    Literal(SpancharString),
    PerlClass(SpanClassPerlKindbool),
    BackReference(Spanu32),
    Dot(Span),
    CharacterClass(SpanCharacterClass),
    Group(SpanGroup),
    Quantifier(SpanBox<Node>, QuantifierKindbool),
    NamedBackReference(SpanString),
}

The tree structure that is used to represent parsed RegEx patterns.

Variants

Empty

An empty regex node.

Disjunction(SpanVec<Node>)

An "either or". (e.g. a|b)

Assertion(SpanAssertionKind)

A single assertion.

Alternative(SpanVec<Node>)

A concatenation of regex nodes. (e.g. ab)

Literal(SpancharString)

A single character literal. The String represents the raw string representing the literal which is used to turn the node back into a string without writing explicit newlines for example.

PerlClass(SpanClassPerlKindbool)

Matches a character class (e.g. \d or \w).

The bool argument indicates if this perl class is negated.

BackReference(Spanu32)

A back reference to a previous group (\1, \2, ...).

Dot(Span)

A . that matches everything.

CharacterClass(SpanCharacterClass)

A class of multiple characters such as [A-Z0-9]

Group(SpanGroup)

A grouped pattern

Quantifier(SpanBox<Node>, QuantifierKindbool)

A quantifier which optionally matches or matches multiple times. bool indicates whether a lazy quantifier (?) is present after it.

NamedBackReference(SpanString)

A reference to a group using a name

Implementations

impl Node[src]

pub fn expanded_nodes(&mut self) -> Box<dyn Iterator<Item = &mut Node>>[src]

if this node is an alternative, yield an iterator over those nodes, otherwise yield the node itself.

pub fn span(&self) -> Option<Span>[src]

get the span of this node, returns None if the node is an empty node.

pub fn is(&self, src: impl AsRef<str>, text: impl AsRef<str>) -> bool[src]

check if this node is equal to some text

pub fn text<'a>(&self, src: &'a str) -> &'a str[src]

pub fn from_string(string: impl AsRef<str>) -> Option<Self>[src]

create a new node from a string. This method is mostly just used for making simple nodes for replacement.

Trait Implementations

impl Clone for Node[src]

impl Debug for Node[src]

impl Eq for Node[src]

impl PartialEq<Node> for Node[src]

impl StructuralEq for Node[src]

impl StructuralPartialEq for Node[src]

impl ToString for Node[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.