Trait sqruff_lib::core::parser::lexer::Matcher

source ·
pub trait Matcher: Debug + DynClone + CloneMatcher + Sync + 'static {
    // Required methods
    fn get_name(&self) -> String;
    fn match_(&self, forward_string: &str) -> Result<LexMatch, ValueError>;
    fn search(&self, forward_string: &str) -> Option<Range<usize>>;
    fn get_sub_divider(&self) -> Option<Box<dyn Matcher>>;
    fn get_trim_post_subdivide(&self) -> Option<Box<dyn Matcher>>;

    // Provided methods
    fn _subdivide(&self, matched: LexedElement) -> Vec<LexedElement> { ... }
    fn _trim_match(&self, matched_str: &str) -> Vec<LexedElement> { ... }
    fn construct_segment(
        &self,
        _raw: String,
        _pos_marker: PositionMarker
    ) -> ErasedSegment { ... }
}

Required Methods§

source

fn get_name(&self) -> String

The name of the matcher.

source

fn match_(&self, forward_string: &str) -> Result<LexMatch, ValueError>

Given a string, match what we can and return the rest.

source

fn search(&self, forward_string: &str) -> Option<Range<usize>>

Use regex to find a substring.

source

fn get_sub_divider(&self) -> Option<Box<dyn Matcher>>

Access methods that need to be implemented by the subclass. Get the sub-divider for this matcher.

source

fn get_trim_post_subdivide(&self) -> Option<Box<dyn Matcher>>

Provided Methods§

source

fn _subdivide(&self, matched: LexedElement) -> Vec<LexedElement>

source

fn _trim_match(&self, matched_str: &str) -> Vec<LexedElement>

Given a string, trim if we are allowed to.

source

fn construct_segment( &self, _raw: String, _pos_marker: PositionMarker ) -> ErasedSegment

Trait Implementations§

source§

impl Display for dyn Matcher

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§

source§

impl<SegmentArgs: Clone + Debug + Sync> Matcher for RegexLexer<SegmentArgs>

source§

impl<SegmentArgs: Clone + Debug + Sync> Matcher for StringLexer<SegmentArgs>