reflex::Matcher Class Reference

|  | reflex::Matcher Class Reference updated Thu Jun 19 2025 by Robert van Engelen |

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
reflex::Matcher Class Reference

RE/flex matcher engine class, implements reflex::PatternMatcher pattern matching interface with scan, find, split functors and iterators. More...

`#include <matcher.h>`

Inheritance diagram for reflex::Matcher:
[legend]
Collaboration diagram for reflex::Matcher:
[legend]

## Classes
struct | FSM
| FSM data for FSM code. More...

## Public Member Functions
| Matcher ()
| Default constructor. More...
| Matcher (const Pattern *pattern, const Input &input=Input(), const char *opt=NULL)
| Construct matcher engine from a pattern, and an input character sequence. More...
| Matcher (const char *pattern, const Input &input=Input(), const char *opt=NULL)
| Construct matcher engine from a string regex, and an input character sequence. More...
| Matcher (const Pattern &pattern, const Input &input=Input(), const char *opt=NULL)
| Construct matcher engine from a pattern, and an input character sequence. More...
| Matcher (const std::string &pattern, const Input &input=Input(), const char *opt=NULL)
| Construct matcher engine from a string regex, and an input character sequence. More...
| Matcher (const Matcher &matcher)
| Copy constructor. More...
virtual Matcher & | operator= (const Matcher &matcher)
| Assign a matcher, the underlying pattern string is shared (not deep copied). More...
virtual Matcher & | pattern (const Pattern &pattern) REFLEX_OVERRIDE
| Set the pattern to use with this matcher (the given pattern is shared and must be persistent). More...
virtual Matcher & | pattern (const Pattern *pattern) REFLEX_OVERRIDE
| Set the pattern to use with this matcher (the given pattern is shared and must be persistent). More...
virtual Matcher & | pattern (const char *pattern) REFLEX_OVERRIDE
| Set the pattern from a regex string to use with this matcher. More...
virtual Matcher & | pattern (const std::string &pattern) REFLEX_OVERRIDE
| Set the pattern from a regex string to use with this matcher. More...
virtual const Pattern & | pattern () const REFLEX_OVERRIDE
| Returns a reference to the pattern associated with this matcher. More...
virtual Matcher * | clone () REFLEX_OVERRIDE
| Polymorphic cloning. More...
virtual void | reset (const char *opt=NULL) REFLEX_OVERRIDE
| Reset this matcher's state to the initial state. More...
virtual std::pair< const char *, size_t > | operator[] (size_t n) const REFLEX_OVERRIDE
| Returns captured text as a std::pair<const char*,size_t> with string pointer (non-0-terminated) and length. More...
virtual std::pair< size_t, const char * > | group_id () REFLEX_OVERRIDE
| Returns the group capture identifier containing the group capture index >0 and name (or NULL) of a named group capture, or (1,NULL) by default. More...
virtual std::pair< size_t, const char * > | group_next_id () REFLEX_OVERRIDE
| Returns the next group capture identifier containing the group capture index >0 and name (or NULL) of a named group capture, or (0,NULL) when no more groups matched. More...
size_t | last_stop ()
| Returns the position of the last indent stop. More...
void | insert_stop (size_t n)
| Inserts or appends an indent stop position, keeping indent stops sorted. More...
void | delete_stop (size_t n)
| Remove all stop positions from position n and up until the last. More...
std::vector< size_t > & | stops ()
| Returns reference to vector of current indent stop positions. More...
void | clear_stops ()
| Clear indent stop positions. More...
void | push_stops ()
| Push current indent stops and clear current indent stops. More...
void | pop_stops ()
| Pop indent stops. More...
void | FSM_INIT (int &c)
| FSM code INIT. More...
void | FSM_FIND ()
| FSM code FIND. More...
int | FSM_CHAR ()
| FSM code CHAR. More...
void | FSM_HALT (int c=AbstractMatcher::Const::UNK)
| FSM code HALT. More...
void | FSM_TAKE (Pattern::Accept cap)
| FSM code TAKE. More...
void | FSM_TAKE (Pattern::Accept cap, int c)
| FSM code TAKE. More...
void | FSM_REDO ()
| FSM code REDO. More...
void | FSM_REDO (int c)
| FSM code REDO. More...
void | FSM_HEAD (Pattern::Lookahead la)
| FSM code HEAD. More...
void | FSM_TAIL (Pattern::Lookahead la)
| FSM code TAIL. More...
bool | FSM_DENT ()
| FSM code DENT. More...
size_t | FSM_POSN ()
| FSM extra code POSN returns current position. More...
void | FSM_BACK (size_t pos)
| FSM extra code BACK position to a previous position returned by FSM_POSN(). More...
bool | FSM_META_DED ()
| FSM code META DED. More...
bool | FSM_META_IND ()
| FSM code META IND. More...
bool | FSM_META_UND ()
| FSM code META UND. More...
bool | FSM_META_EOB (int c)
| FSM code META EOB. More...
bool | FSM_META_BOB ()
| FSM code META BOB. More...
bool | FSM_META_EOL (int c)
| FSM code META EOL. More...
bool | FSM_META_BOL ()
| FSM code META BOL. More...
bool | FSM_META_EWE (int c)
| FSM code META EWE. More...
bool | FSM_META_BWE (int c)
| FSM code META BWE. More...
bool | FSM_META_EWB ()
| FSM code META EWB. More...
bool | FSM_META_BWB ()
| FSM code META BWB. More...
bool | FSM_META_NWE (int c)
| FSM code META NWE. More...
bool | FSM_META_NWB ()
| FSM code META NWB. More...
bool | FSM_META_WBE (int c)
| FSM code META WBE. More...
bool | FSM_META_WBB ()
| FSM code META WBB. More...
Public Member Functions inherited from reflex::PatternMatcher< reflex::Pattern >
| PatternMatcher (const PatternMatcher &matcher)
| Copy constructor, the underlying pattern object is shared (not deep copied). More...
virtual | ~PatternMatcher ()
| Delete matcher, deletes pattern when owned. More...
virtual PatternMatcher & | operator= (const PatternMatcher &matcher)
| Assign a matcher, the underlying pattern object is shared (not deep copied). More...
virtual PatternMatcher & | pattern (const PatternMatcher &matcher)
| Set the pattern to use with this matcher as a shared pointer to another matcher pattern. More...
bool | has_pattern () const
| Returns true if this matcher has a pattern. More...
bool | own_pattern () const
| Returns true if this matcher has its own pattern not received from another matcher (responsible to delete). More...
Public Member Functions inherited from reflex::AbstractMatcher
| AbstractMatcher (const Input &input, const char *opt)
| Construct a base abstract matcher. More...
| AbstractMatcher (const Input &input, const Option &opt)
| Construct a base abstract matcher. More...
virtual | ~AbstractMatcher ()
| Delete abstract matcher, deletes this matcher's internal buffer. More...
bool | buffer (size_t blk=0)
| Set buffer block size for reading: use 0 (or omit argument) to buffer all input in which case returns true if all the data could be read and false if a read error occurred. More...
void | set_handler (Handler *handler)
| Set event handler functor to invoke when the buffer contents are shifted out, e.g. for logging the data searched. More...
void | handle ()
| Invoke handler explicitly (externally) with zero shift distance. More...
void | set_reserve (size_t n)
| Set reserved bytes for buffer shifting. More...
Context | before ()
| Get the buffered context before the matching line. More...
Context | after ()
| Get the buffered context after EOF is reached. More...
void | interactive ()
| Set interactive input with buffer size of 1 to read data bytewise which is very slow. More...
void | flush ()
| Flush and delete the buffer's remaining content. More...
virtual size_t | get (char *s, size_t n)
| Returns more input data directly from the source (method can be overriden, as by reflex::FlexLexer::get(s, n) for example that invokes reflex::FlexLexer::LexerInput(s, n)). More...
virtual bool | wrap ()
| Returns true if wrapping of input after EOF is supported. More...
virtual AbstractMatcher & | input (const Input &input)
| Set the input character sequence for this matcher and reset/restart the matcher. More...
AbstractMatcher & | buffer (char *base, size_t size)
| Set the buffer base containing 0-terminated character data to scan in place (data may be modified), reset/restart the matcher. More...
size_t | matches ()
| Returns nonzero capture index (i.e. true) if the entire input matches this matcher's pattern (and internally caches the true/false result to permit repeat invocations). More...
size_t | accept () const
| Returns a positive integer (true) indicating the capture index of the matched text in the pattern or zero (false) for a mismatch. More...
const char * | begin () const
| Returns pointer to the begin of the matched text (non-0-terminated), a constant-time operation, use with end() or use size() for text end/length. More...
const char * | end () const
| Returns pointer to the exclusive end of the matched text, a constant-time operation. More...
const char * | text ()
| Returns 0-terminated pattern match as a char pointer, does not include matched \0s, this is a constant-time operation. More...
std::string | str () const
| Returns the text matched as a string, a copy of text(), may include pattern-matched \0s. More...
std::wstring | wstr () const
| Returns the pattern match as a wide string, converted from UTF-8 text(), may include pattern-matched \0s. More...
size_t | size () const
| Returns the length of the matched text in number of bytes, including pattern-matched \0s, a constant-time operation. More...
size_t | wsize () const
| Returns the length of the matched text in number of wide characters. More...
int | chr () const
| Returns the first 8-bit character of the text matched. More...
int | wchr () const
| Returns the first wide character of the text matched. More...
void | lineno_skip (bool f=false)
| Set or reset mode to count matching lines only and skip all other (e.g. for speed). More...
void | lineno (size_t n)
| Set or change the starting line number of the last match. More...
size_t | lineno ()
| Updates and returns the starting line number of the match in the input character sequence. More...
size_t | lines ()
| Returns the number of lines that the match spans. More...
size_t | lineno_end ()
| Returns the inclusive ending line number of the match in the input character sequence. More...
void | columno (size_t n)
| Set or change the starting column number of the last match. More...
size_t | columno ()
| Updates and returns the starting column number of the matched text, taking tab spacing into account and counting wide characters as one character each. More...
size_t | columns ()
| Returns the number of columns of the matched text, taking tab spacing into account and counting wide characters as one character each. More...
size_t | columno_end ()
| Returns the inclusive ending column number of the matched text on the ending matching line, taking tab spacing into account and counting wide characters as one character each. More...
std::pair< size_t, std::string > | pair () const
| Returns std::pair<size_t,std::string>(accept(), str()), useful for tokenizing input into containers of pairs. More...
std::pair< size_t, std::wstring > | wpair () const
| Returns std::pair<size_t,std::wstring>(accept(), wstr()), useful for tokenizing input into containers of pairs. More...
size_t | first () const
| Returns the position of the first character of the match in the input character sequence, a constant-time operation. More...
size_t | last () const
| Returns the exclusive position of the last character of the match in the input character sequence, a constant-time operation. More...
bool | at_bob () const
| Returns true if this matcher is at the start of a buffer to read an input character sequence. Use reset() to restart reading new input. More...
void | set_bob (bool bob)
| Set/reset the begin of a buffer state. More...
bool | at_end ()
| Returns true if this matcher has no more input to read from the input character sequence. More...
bool | hit_end () const
| Returns true if this matcher hit the end of the input character sequence. More...
void | set_end (bool eof)
| Set and force the end of input state. More...
bool | at_bol () const
| Returns true if this matcher reached the begin of a new line. More...
void | set_bol (bool bol)
| Set/reset the begin of a new line state. More...
bool | at_bow ()
| Returns true if this matcher matched text that begins an ASCII word. More...
bool | at_eow ()
| Returns true if this matcher matched text that ends an ASCII word. More...
int | input ()
| Returns the next 8-bit character (unsigned char 0..255 or EOF) from the input character sequence, while preserving the current text() match (but pointer returned by text() may change; warning: does not preserve the yytext string pointer when options –flex and –bison are used). More...
int | winput ()
| Returns the next wide character (unsigned 0..U+10FFFF or EOF) from the input character sequence, while preserving the current text() match (but pointer returned by text() may change; warning: does not preserve the yytext string pointer when options –flex and –bison are used). More...
void | unput (char c)
| Put back one character (8-bit) on the input character sequence for matching, DANGER: invalidates the previous text() pointer and match info, unput is not honored when matching in-place using buffer(base, size) and nothing has been read yet. More...
void | wunput (int c)
| Put back one (wide) character on the input character sequence for matching, DANGER: invalidates the previous text() pointer and match info, unput is not honored when matching in-place using buffer(base, size) and nothing has been read yet. More...
int | peek ()
| Peek at the next character available for reading from the current input source. More...
const char * | bol ()
| Returns pointer to the begin of the line in the buffer containing the matched text. More...
const char * | eol (bool inclusive=false)
| Returns pointer to the end of the line (last char + 1) in the buffer containing the matched text, DANGER: invalidates previous bol() and text() pointers, use eol() before bol(), text(), begin(), and end() when those are used. More...
const char * | aft (size_t len)
| Return pointer to the end of the match + len after, or at end of file, DANGER: invalidates previous bol() and text() pointers, use aft() before bol(), text(), begin(), and end() when those are used. More...
const char * | bef (size_t len)
| Return pointer to the begin of the match - len before, or at the begin of the file. More...
size_t | fetch (size_t len)
| Return number of bytes available given number of bytes to fetch ahead, limited by input size and buffer size, DANGER: invalidates previous bol() and text() pointers, use fetch() before bol(), text(), begin(), and end() when those are used. More...
size_t | avail ()
| Returns the number of bytes in the buffer available to search from the current begin()/text() position. More...
size_t | border ()
| Returns the byte offset of the match from the start of the line. More...
const char * | span ()
| Enlarge the match to span the entire line of input (excluding ), return text(). More...
std::string | line ()
| Returns the line of input (excluding ) as a string containing the matched text as a substring. More...
std::wstring | wline ()
| Returns the line of input (excluding ) as a wide string containing the matched text as a substring. More...
bool | skip (char c)
| Skip input until the specified ASCII character is consumed and return true, or EOF is reached and return false. More...
bool | skip (wchar_t c)
| Skip input until the specified Unicode character is consumed and return true, or EOF is reached and return false. More...
bool | skip (const char *s)
| Skip input until the specified literal UTF-8 string is consumed and return true, or EOF is reached and return false. More...
const char * | rest ()
| Fetch the rest of the input as text, useful for searching/splitting up to n times after which the rest is needed. More...
void | more ()
| Append the next match to the currently matched text returned by AbstractMatcher::text, when the next match found is adjacent to the current match. More...
void | less (size_t n)
| Truncate the AbstractMatcher::text length of the match to n characters in length and reposition for next match. More...
| operator size_t () const
| Cast this matcher to positive integer indicating the nonzero capture index of the matched text in the pattern, same as AbstractMatcher::accept. More...
| operator std::string () const
| Cast this matcher to a std::string of the text matched by this matcher. More...
| operator std::wstring () const
| Cast this matcher to a std::wstring of the text matched by this matcher. More...
| operator std::pair< size_t, std::string > () const
| Cast the match to std::pair<size_t,std::wstring>(accept(), wstr()), useful for tokenization into containers. More...
bool | operator== (const char *rhs) const
| Returns true if matched text is equal to a string, useful for std::algorithm. More...
bool | operator== (const std::string &rhs) const
| Returns true if matched text is equalt to a string, useful for std::algorithm. More...
bool | operator== (size_t rhs) const
| Returns true if capture index is equal to a given size_t value, useful for std::algorithm. More...
bool | operator== (int rhs) const
| Returns true if capture index is equal to a given int value, useful for std::algorithm. More...
bool | operator!= (const char *rhs) const
| Returns true if matched text is not equal to a string, useful for std::algorithm. More...
bool | operator!= (const std::string &rhs) const
| Returns true if matched text is not equal to a string, useful for std::algorithm. More...
bool | operator!= (size_t rhs) const
| Returns true if capture index is not equal to a given size_t value, useful for std::algorithm. More...
bool | operator!= (int rhs) const
| Returns true if capture index is not equal to a given int value, useful for std::algorithm. More...
void | tabs (char n)
| Set tab size 1, 2, 4, or 8. More...
char | tabs ()
| Returns current tab size 1, 2, 4, or 8. More...

## Static Public Member Functions
template<typename T >
static std::string | convert (T regex, convert_flag_type flags=convert_flag::none, bool *multiline=NULL)
| Convert a regex to an acceptable form, given the specified regex library signature `"[decls:]escapes[?+]"`, see reflex::convert. More...

## Protected Types
typedef std::vector< size_t > | Stops
Protected Types inherited from reflex::AbstractMatcher
typedef int | Method
| a method is one of Const::SCAN, Const::FIND, Const::SPLIT, Const::MATCH More...

## Protected Member Functions
bool | at_wb ()
| Check if a word begins before a match. More...
bool | at_we (int c, size_t k)
| Check if a word ends after the match. More...
bool | at_bw ()
| Check if match begins a word (after split with len_ > 0 or len_ = 0 for find). More...
bool | at_ew (int c)
| Check if match ends a word. More...
bool | at_ewe (int c)
| Check end of word at match end boundary MATCH> at pos. More...
bool | at_bwe (int c)
| Check begin of word at match end boundary MATCH< at pos. More...
bool | at_ewb ()
| Check end of word at match begin boundary >MATCH after matching (SPLIT len_ > 0 or len_ = 0 for FIND). More...
bool | at_bwb ()
| Check begin of word at match begin boundary <MATCH after matching (SPLIT len_ > 0 or len_ = 0 for FIND). More...
bool | at_nwe (int c)
| Check not a word boundary at match end MATCH at pos. More...
bool | at_nwb ()
| Check not a word boundary at match begin after matching (SPLIT len_ > 0 or len_ = 0 for FIND). More...
bool | at_wbe (int c)
| Check word boundary at match end MATCHat pos. More...
bool | at_wbb ()
| Check word boundary at match begin after matching (SPLIT len_ > 0 or len_ = 0 for FIND). More...
virtual size_t | match (Method method) REFLEX_OVERRIDE
| Returns true if input matched the pattern using method Const::SCAN, Const::FIND, Const::SPLIT, or Const::MATCH. More...
size_t | simd_match_avx512bw (Method method)
| match() with optimized AVX512BW string search scheme defined in matcher_avx512bw.cpp More...
size_t | simd_match_avx2 (Method method)
| match() with optimized AVX2 string search scheme defined in matcher_avx2.cpp More...
void | init_advance ()
| Initialize specialized (+ SSE2/NEON) pattern search methods to advance the engine to a possible match. More...
void | simd_init_advance_avx2 ()
| Initialize specialized AVX2 pattern search methods to advance the engine to a possible match. More...
void | simd_init_advance_avx512bw ()
| Initialize specialized AVX512BW pattern search methods to advance the engine to a possible match. More...
bool | advance_none (size_t loc)
| Default method is none (unset) More...
bool | advance_pattern_pin1_one (size_t loc)
bool | advance_pattern_pin1_pma (size_t loc)
bool | advance_pattern_pin2_one (size_t loc)
bool | advance_pattern_pin2_pma (size_t loc)
bool | advance_pattern_pin3_one (size_t loc)
bool | advance_pattern_pin3_pma (size_t loc)
bool | advance_pattern_pin4_one (size_t loc)
bool | advance_pattern_pin4_pma (size_t loc)
bool | advance_pattern_pin5_one (size_t loc)
bool | advance_pattern_pin5_pma (size_t loc)
bool | advance_pattern_pin6_one (size_t loc)
bool | advance_pattern_pin6_pma (size_t loc)
bool | advance_pattern_pin7_one (size_t loc)
bool | advance_pattern_pin7_pma (size_t loc)
bool | advance_pattern_pin8_one (size_t loc)
bool | advance_pattern_pin8_pma (size_t loc)
bool | simd_advance_pattern_pin1_pma_avx2 (size_t loc)
bool | simd_advance_pattern_pin2_one_avx2 (size_t loc)
bool | simd_advance_pattern_pin2_pma_avx2 (size_t loc)
bool | simd_advance_pattern_pin3_one_avx2 (size_t loc)
bool | simd_advance_pattern_pin3_pma_avx2 (size_t loc)
bool | simd_advance_pattern_pin4_one_avx2 (size_t loc)
bool | simd_advance_pattern_pin4_pma_avx2 (size_t loc)
bool | simd_advance_pattern_pin5_one_avx2 (size_t loc)
bool | simd_advance_pattern_pin5_pma_avx2 (size_t loc)
bool | simd_advance_pattern_pin6_one_avx2 (size_t loc)
bool | simd_advance_pattern_pin6_pma_avx2 (size_t loc)
bool | simd_advance_pattern_pin7_one_avx2 (size_t loc)
bool | simd_advance_pattern_pin7_pma_avx2 (size_t loc)
bool | simd_advance_pattern_pin8_one_avx2 (size_t loc)
bool | simd_advance_pattern_pin8_pma_avx2 (size_t loc)
bool | simd_advance_pattern_pin16_one_avx2 (size_t loc)
bool | simd_advance_pattern_pin16_pma_avx2 (size_t loc)
bool | advance_pattern_min1 (size_t loc)
bool | advance_pattern_min2 (size_t loc)
bool | advance_pattern_min3 (size_t loc)
bool | advance_pattern_mink (size_t loc)
bool | advance_char (size_t loc)
bool | advance_char_pma (size_t loc)
template<uint8_t LEN>
bool | advance_chars (size_t loc)
template<uint8_t LEN>
bool | advance_chars_pma (size_t loc)
template<uint8_t LEN>
bool | simd_advance_chars_avx2 (size_t loc)
template<uint8_t LEN>
bool | simd_advance_chars_pma_avx2 (size_t loc)
template<uint8_t LEN>
bool | simd_advance_chars_avx512bw (size_t loc)
template<uint8_t LEN>
bool | simd_advance_chars_pma_avx512bw (size_t loc)
bool | advance_string (size_t loc)
bool | advance_string_pma (size_t loc)
bool | simd_advance_string_avx2 (size_t loc)
bool | simd_advance_string_pma_avx2 (size_t loc)
bool | simd_advance_string_avx512bw (size_t loc)
bool | simd_advance_string_pma_avx512bw (size_t loc)
bool | simd_advance_string_neon (const char *&s, const char *e)
bool | simd_advance_string_pma_neon (const char *&s, const char *e)
bool | advance_string_bm (size_t loc)
bool | advance_string_bm_pma (size_t loc)
void | newline ()
| Update indentation column counter for indent() and dedent(). More...
bool | indent ()
| Returns true if looking at indent. More...
bool | dedent ()
| Returns true if looking at dedent. More...
bool | nodent ()
| Returns true if nodent. More...
Protected Member Functions inherited from reflex::PatternMatcher< reflex::Pattern >
| PatternMatcher (const Pattern *pattern=NULL, const Input &input=Input(), const char *opt=NULL)
| Construct a base abstract matcher from a pointer to a persistent pattern object (that is shared with this class) and an input character sequence. More...
| PatternMatcher (const Pattern &pattern, const Input &input=Input(), const char *opt=NULL)
| Construct a base abstract matcher from a persistent pattern object (that is shared with this class) and an input character sequence. More...
| PatternMatcher (const char *pattern, const Input &input=Input(), const char *opt=NULL)
| Construct a base abstract matcher from a regex pattern string and an input character sequence. More...
| PatternMatcher (const std::string &pattern, const Input &input=Input(), const char *opt=NULL)
| Construct a base abstract matcher from a regex pattern string and an input character sequence. More...
Protected Member Functions inherited from reflex::AbstractMatcher
virtual void | init (const char *opt=NULL)
| Initialize the base abstract matcher at construction. More...
bool | grow (size_t need=Const::BLOCK)
| Shift or expand the internal buffer when it is too small to accommodate more input, where the buffer size is doubled when needed, change cur_, pos_, end_, max_, ind_, buf_, bol_, lpb_, and txt_. More...
int | get ()
| Returns the next character read from the current input source. More...
void | reset_text ()
| Reset the matched text by removing the terminating \0 when applicable, which is needed to search for a new match. More...
void | set_current (size_t loc)
| Set the current position in the buffer for the next match. More...
void | set_current_and_peek_more (size_t loc)
| Set the current match position in the buffer and peek for more text, allows large buffer shifts that aren't pinned to txt_. More...
int | get_more ()
| Get the next character and grow the buffer to make more room if necessary, unless EOF. More...
int | peek_more ()
| Peek at the next character and grow the buffer to make more room if necessary, unless EOF. More...

## Static Protected Member Functions
static bool | iswword (int c)
| Return true if Unicode word character. More...

## Protected Attributes
size_t | ded_
| dedent count More...
size_t | col_
| column counter for indent matching, updated by newline(), indent(), and dedent() More...
Stops | tab_
| tab stops set by detecting indent margins More...
std::vector< int > | lap_
| lookahead position in input that heads a lookahead match (indexed by lookahead number) More...
std::stack< Stops > | stk_
| stack to push/pop stops More...
FSM | fsm_
| local state for FSM code More...
bool(Matcher::* | adv_ )(size_t loc)
| advance FIND function pointer More...
bool | mrk_
| indent or dedent in pattern found: should check and update indent stops More...
Protected Attributes inherited from reflex::PatternMatcher< reflex::Pattern >
const Pattern * | pat_
| points to the pattern object used by the matcher More...
bool | del_
| true if PatternMatcher::pat_ was allocated and should be deleted More...
Protected Attributes inherited from reflex::AbstractMatcher
Option | opt_
| options for matcher engines More...
char * | buf_
| input character sequence buffer More...
char * | txt_
| points to the matched text in buffer AbstractMatcher::buf_ More...
size_t | len_
| size of the matched text More...
size_t | cap_
| nonzero capture index of an accepted match or zero More...
size_t | cur_
| next position in AbstractMatcher::buf_ to assign to AbstractMatcher::txt_ More...
size_t | pos_
| position in AbstractMatcher::buf_ after AbstractMatcher::txt_ More...
size_t | end_
| ending position of the input buffered in AbstractMatcher::buf_ More...
size_t | max_
| total buffer size and max position + 1 to fill More...
size_t | ind_
| current indent position More...
size_t | blk_
| block size for block-based input reading, as set by AbstractMatcher::buffer More...
int | got_
| last unsigned character we looked at (to determine anchors and boundaries) More...
int | chr_
| the character located at AbstractMatcher::txt_[AbstractMatcher::len_] More...
const char * | bol_
| begin of line pointer in buffer More...
Handler * | evh_
| event handler functor to invoke when buffer contents are shifted out More...
const char * | lpb_
| line pointer in buffer, updated when counting line numbers with lineno() More...
size_t | lno_
| line number count (cached) More...
const char * | cpb_
| column pointer in buffer, updated when counting column numbers with columno() More...
size_t | cno_
| column number count (cached) More...
size_t | num_
| character count of the input till bol_ More...
size_t | res_
| reserve bytes to keep in the buffer before bol_ when shifting More...
bool | own_
| true if AbstractMatcher::buf_ was allocated and should be deleted More...
bool | eof_
| input has reached EOF More...
bool | mat_
| true if AbstractMatcher::matches() was successful More...
bool | cml_
| true when counting matching lines instead of line numbers More...

## Additional Inherited Members
Public Types inherited from reflex::PatternMatcher< reflex::Pattern >
typedef reflex::Pattern | Pattern
Public Types inherited from reflex::AbstractMatcher
typedef AbstractMatcher::Iterator< AbstractMatcher > | iterator
| std::input_iterator for scanning, searching, and splitting input character sequences More...
typedef AbstractMatcher::Iterator< const AbstractMatcher > | const_iterator
Public Attributes inherited from reflex::AbstractMatcher
Operation | scan
| functor to scan input (to tokenize input) More...
Operation | find
| functor to search input More...
Operation | split
| functor to split input More...
Input | in
| input character sequence being matched by this matcher More...

## Detailed Description

RE/flex matcher engine class, implements reflex::PatternMatcher pattern matching interface with scan, find, split functors and iterators.

## Member Typedef Documentation

typedef std::vector<size_t> reflex::Matcher::Stops
| protected

indent margin/tab stops

## Constructor & Destructor Documentation

reflex::Matcher::Matcher | ( |  | ) |
| inline

Default constructor.

reflex::Matcher::Matcher | ( | const Pattern * | pattern,
|  | const Input & | input = `Input()`,
|  | const char * | opt = `NULL`
| ) |  |
| inline

Construct matcher engine from a pattern, and an input character sequence.

Parameters

  pattern | points to a reflex::Pattern
  input | input character sequence for this matcher
  opt | option string of the form `(A|N|T(=[[:digit:]])?|;)*`

reflex::Matcher::Matcher | ( | const char * | pattern,
|  | const Input & | input = `Input()`,
|  | const char * | opt = `NULL`
| ) |  |
| inline

Construct matcher engine from a string regex, and an input character sequence.

Parameters

  pattern | a string regex for this matcher
  input | input character sequence for this matcher
  opt | option string of the form `(A|N|T(=[[:digit:]])?|;)*`

reflex::Matcher::Matcher | ( | const Pattern & | pattern,
|  | const Input & | input = `Input()`,
|  | const char * | opt = `NULL`
| ) |  |
| inline

Construct matcher engine from a pattern, and an input character sequence.

Parameters

  pattern | a reflex::Pattern
  input | input character sequence for this matcher
  opt | option string of the form `(A|N|T(=[[:digit:]])?|;)*`

reflex::Matcher::Matcher | ( | const std::string & | pattern,
|  | const Input & | input = `Input()`,
|  | const char * | opt = `NULL`
| ) |  |
| inline

Construct matcher engine from a string regex, and an input character sequence.

Parameters

  pattern | a reflex::Pattern or a string regex for this matcher
  input | input character sequence for this matcher
  opt | option string of the form `(A|N|T(=[[:digit:]])?|;)*`

reflex::Matcher::Matcher | ( | const Matcher & | matcher | ) |
| inline

Copy constructor.

Parameters

  matcher | matcher to copy with pattern (pattern may be shared)

## Member Function Documentation

bool reflex::Matcher::advance_char | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_char_pma | ( | size_t | loc | ) |
| protected

template<uint8_t LEN>

bool reflex::Matcher::advance_chars | ( | size_t | loc | ) |
| protected

template<uint8_t LEN>

bool reflex::Matcher::advance_chars_pma | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_none | ( | size_t | loc | ) |
| protected

Default method is none (unset)

bool reflex::Matcher::advance_pattern_min1 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_min2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_min3 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_mink | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin1_one | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin1_pma | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin2_one | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin2_pma | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin3_one | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin3_pma | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin4_one | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin4_pma | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin5_one | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin5_pma | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin6_one | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin6_pma | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin7_one | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin7_pma | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin8_one | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_pattern_pin8_pma | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_string | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_string_bm | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_string_bm_pma | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::advance_string_pma | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::at_bw | ( |  | ) |
| inlineprotected

Check if match begins a word (after split with len_ > 0 or len_ = 0 for find).

bool reflex::Matcher::at_bwb | ( |  | ) |
| inlineprotected

Check begin of word at match begin boundary <MATCH after matching (SPLIT len_ > 0 or len_ = 0 for FIND).

bool reflex::Matcher::at_bwe | ( | int | c | ) |
| inlineprotected

Check begin of word at match end boundary MATCH< at pos.

Parameters

  c | character last read with get()

bool reflex::Matcher::at_ew | ( | int | c | ) |
| inlineprotected

Check if match ends a word.

bool reflex::Matcher::at_ewb | ( |  | ) |
| inlineprotected

Check end of word at match begin boundary >MATCH after matching (SPLIT len_ > 0 or len_ = 0 for FIND).

bool reflex::Matcher::at_ewe | ( | int | c | ) |
| inlineprotected

Check end of word at match end boundary MATCH> at pos.

Parameters

  c | character last read with get()

bool reflex::Matcher::at_nwb | ( |  | ) |
| inlineprotected

Check not a word boundary at match begin after matching (SPLIT len_ > 0 or len_ = 0 for FIND).

bool reflex::Matcher::at_nwe | ( | int | c | ) |
| inlineprotected

Check not a word boundary at match end MATCH at pos.

Parameters

  c | character last read with get()

bool reflex::Matcher::at_wb | ( |  | ) |
| inlineprotected

Check if a word begins before a match.

bool reflex::Matcher::at_wbb | ( |  | ) |
| inlineprotected

Check word boundary at match begin after matching (SPLIT len_ > 0 or len_ = 0 for FIND).

bool reflex::Matcher::at_wbe | ( | int | c | ) |
| inlineprotected

Check word boundary at match end MATCHat pos.

Parameters

  c | character last read with get()

bool reflex::Matcher::at_we | ( | int | c,
|  | size_t | k
| ) |  |
| inlineprotected

Check if a word ends after the match.

Parameters

  c | character after the match
  k | position in the buffer of the character after the match

void reflex::Matcher::clear_stops | ( |  | ) |
| inline

Clear indent stop positions.

virtual Matcher* reflex::Matcher::clone | ( |  | ) |
| inlinevirtual

Polymorphic cloning.

Implements reflex::AbstractMatcher.

Reimplemented in reflex::FuzzyMatcher.

template<typename T >

static std::string reflex::Matcher::convert | ( | T | regex,
|  | convert_flag_type | flags = `convert_flag::none`,
|  | bool * | multiline = `NULL`
| ) |  |
| inlinestatic

Convert a regex to an acceptable form, given the specified regex library signature `"[decls:]escapes[?+]"`, see reflex::convert.

bool reflex::Matcher::dedent | ( |  | ) |
| inlineprotected

Returns true if looking at dedent.

Returns
  true if dedent

void reflex::Matcher::delete_stop | ( | size_t | n | ) |
| inline

Remove all stop positions from position n and up until the last.

void reflex::Matcher::FSM_BACK | ( | size_t | pos | ) |
| inline

FSM extra code BACK position to a previous position returned by FSM_POSN().

int reflex::Matcher::FSM_CHAR | ( |  | ) |
| inline

FSM code CHAR.

bool reflex::Matcher::FSM_DENT | ( |  | ) |
| inline

FSM code DENT.

void reflex::Matcher::FSM_FIND | ( |  | ) |
| inline

FSM code FIND.

void reflex::Matcher::FSM_HALT | ( | int | c = `AbstractMatcher::Const::UNK` | ) |
| inline

FSM code HALT.

void reflex::Matcher::FSM_HEAD | ( | Pattern::Lookahead | la | ) |
| inline

FSM code HEAD.

void reflex::Matcher::FSM_INIT | ( | int & | c | ) |
| inline

FSM code INIT.

bool reflex::Matcher::FSM_META_BOB | ( |  | ) |
| inline

FSM code META BOB.

bool reflex::Matcher::FSM_META_BOL | ( |  | ) |
| inline

FSM code META BOL.

bool reflex::Matcher::FSM_META_BWB | ( |  | ) |
| inline

FSM code META BWB.

bool reflex::Matcher::FSM_META_BWE | ( | int | c | ) |
| inline

FSM code META BWE.

bool reflex::Matcher::FSM_META_DED | ( |  | ) |
| inline

FSM code META DED.

bool reflex::Matcher::FSM_META_EOB | ( | int | c | ) |
| inline

FSM code META EOB.

bool reflex::Matcher::FSM_META_EOL | ( | int | c | ) |
| inline

FSM code META EOL.

bool reflex::Matcher::FSM_META_EWB | ( |  | ) |
| inline

FSM code META EWB.

bool reflex::Matcher::FSM_META_EWE | ( | int | c | ) |
| inline

FSM code META EWE.

bool reflex::Matcher::FSM_META_IND | ( |  | ) |
| inline

FSM code META IND.

bool reflex::Matcher::FSM_META_NWB | ( |  | ) |
| inline

FSM code META NWB.

bool reflex::Matcher::FSM_META_NWE | ( | int | c | ) |
| inline

FSM code META NWE.

bool reflex::Matcher::FSM_META_UND | ( |  | ) |
| inline

FSM code META UND.

bool reflex::Matcher::FSM_META_WBB | ( |  | ) |
| inline

FSM code META WBB.

bool reflex::Matcher::FSM_META_WBE | ( | int | c | ) |
| inline

FSM code META WBE.

size_t reflex::Matcher::FSM_POSN | ( |  | ) |
| inline

FSM extra code POSN returns current position.

void reflex::Matcher::FSM_REDO | ( |  | ) |
| inline

FSM code REDO.

void reflex::Matcher::FSM_REDO | ( | int | c | ) |
| inline

FSM code REDO.

void reflex::Matcher::FSM_TAIL | ( | Pattern::Lookahead | la | ) |
| inline

FSM code TAIL.

void reflex::Matcher::FSM_TAKE | ( | Pattern::Accept | cap | ) |
| inline

FSM code TAKE.

void reflex::Matcher::FSM_TAKE | ( | Pattern::Accept | cap,
|  | int | c
| ) |  |
| inline

FSM code TAKE.

virtual std::pair<size_t,const char*> reflex::Matcher::group_id | ( |  | ) |
| inlinevirtual

Returns the group capture identifier containing the group capture index >0 and name (or NULL) of a named group capture, or (1,NULL) by default.

Returns
  a pair of size_t and string

Implements reflex::AbstractMatcher.

virtual std::pair<size_t,const char*> reflex::Matcher::group_next_id | ( |  | ) |
| inlinevirtual

Returns the next group capture identifier containing the group capture index >0 and name (or NULL) of a named group capture, or (0,NULL) when no more groups matched.

Returns
  (0,NULL)

Implements reflex::AbstractMatcher.

bool reflex::Matcher::indent | ( |  | ) |
| inlineprotected

Returns true if looking at indent.

Returns
  true if indent

void reflex::Matcher::init_advance | ( |  | ) |
| protected

Initialize specialized (+ SSE2/NEON) pattern search methods to advance the engine to a possible match.

void reflex::Matcher::insert_stop | ( | size_t | n | ) |
| inline

Inserts or appends an indent stop position, keeping indent stops sorted.

static bool reflex::Matcher::iswword | ( | int | c | ) |
| inlinestaticprotected

Return true if Unicode word character.

Parameters

  c | character to test

size_t reflex::Matcher::last_stop | ( |  | ) |
| inline

Returns the position of the last indent stop.

virtual size_t reflex::Matcher::match | ( | Method | method | ) |
| protectedvirtual

Returns true if input matched the pattern using method Const::SCAN, Const::FIND, Const::SPLIT, or Const::MATCH.

Returns
  nonzero if input matched the pattern

Parameters

  method | Const::SCAN, Const::FIND, Const::SPLIT, or Const::MATCH

Implements reflex::AbstractMatcher.

Reimplemented in reflex::FuzzyMatcher.

void reflex::Matcher::newline | ( |  | ) |
| inlineprotected

Update indentation column counter for indent() and dedent().

bool reflex::Matcher::nodent | ( |  | ) |
| inlineprotected

Returns true if nodent.

Returns
  true if nodent

virtual Matcher& reflex::Matcher::operator= | ( | const Matcher & | matcher | ) |
| inlinevirtual

Assign a matcher, the underlying pattern string is shared (not deep copied).

Parameters

  matcher | matcher to copy

virtual std::pair<const char*,size_t> reflex::Matcher::operator[] | ( | size_t | n | ) | const
| inlinevirtual

Returns captured text as a std::pair<const char*,size_t> with string pointer (non-0-terminated) and length.

Implements reflex::AbstractMatcher.

virtual Matcher& reflex::Matcher::pattern | ( | const Pattern & | pattern | ) |
| inlinevirtual

Set the pattern to use with this matcher (the given pattern is shared and must be persistent).

Returns
  this matcher

Parameters

  pattern | pattern object for this matcher

Reimplemented from reflex::PatternMatcher< reflex::Pattern >.

virtual Matcher& reflex::Matcher::pattern | ( | const Pattern * | pattern | ) |
| inlinevirtual

Set the pattern to use with this matcher (the given pattern is shared and must be persistent).

Returns
  this matcher

Parameters

  pattern | pattern object for this matcher

Reimplemented from reflex::PatternMatcher< reflex::Pattern >.

virtual Matcher& reflex::Matcher::pattern | ( | const char * | pattern | ) |
| inlinevirtual

Set the pattern from a regex string to use with this matcher.

Returns
  this matcher

Parameters

  pattern | regex string to instantiate internal pattern object

Reimplemented from reflex::PatternMatcher< reflex::Pattern >.

virtual Matcher& reflex::Matcher::pattern | ( | const std::string & | pattern | ) |
| inlinevirtual

Set the pattern from a regex string to use with this matcher.

Returns
  this matcher

Parameters

  pattern | regex string to instantiate internal pattern object

Reimplemented from reflex::PatternMatcher< reflex::Pattern >.

virtual const Pattern& reflex::Matcher::pattern | ( |  | ) | const
| inlinevirtual

Returns a reference to the pattern associated with this matcher.

Returns
  reference to pattern

Reimplemented from reflex::PatternMatcher< reflex::Pattern >.

void reflex::Matcher::pop_stops | ( |  | ) |
| inline

Pop indent stops.

void reflex::Matcher::push_stops | ( |  | ) |
| inline

Push current indent stops and clear current indent stops.

virtual void reflex::Matcher::reset | ( | const char * | opt = `NULL` | ) |
| inlinevirtual

Reset this matcher's state to the initial state.

Reimplemented from reflex::AbstractMatcher.

template<uint8_t LEN>

bool reflex::Matcher::simd_advance_chars_avx2 | ( | size_t | loc | ) |
| protected

template<uint8_t LEN>

bool reflex::Matcher::simd_advance_chars_avx512bw | ( | size_t | loc | ) |
| protected

template<uint8_t LEN>

bool reflex::Matcher::simd_advance_chars_pma_avx2 | ( | size_t | loc | ) |
| protected

template<uint8_t LEN>

bool reflex::Matcher::simd_advance_chars_pma_avx512bw | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin16_one_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin16_pma_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin1_pma_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin2_one_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin2_pma_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin3_one_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin3_pma_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin4_one_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin4_pma_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin5_one_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin5_pma_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin6_one_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin6_pma_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin7_one_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin7_pma_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin8_one_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_pattern_pin8_pma_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_string_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_string_avx512bw | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_string_neon | ( | const char *& | s,
|  | const char * | e
| ) |  |
| protected

bool reflex::Matcher::simd_advance_string_pma_avx2 | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_string_pma_avx512bw | ( | size_t | loc | ) |
| protected

bool reflex::Matcher::simd_advance_string_pma_neon | ( | const char *& | s,
|  | const char * | e
| ) |  |
| protected

void reflex::Matcher::simd_init_advance_avx2 | ( |  | ) |
| protected

Initialize specialized AVX2 pattern search methods to advance the engine to a possible match.

void reflex::Matcher::simd_init_advance_avx512bw | ( |  | ) |
| protected

Initialize specialized AVX512BW pattern search methods to advance the engine to a possible match.

size_t reflex::Matcher::simd_match_avx2 | ( | Method | method | ) |
| protected

match() with optimized AVX2 string search scheme defined in matcher_avx2.cpp

size_t reflex::Matcher::simd_match_avx512bw | ( | Method | method | ) |
| protected

match() with optimized AVX512BW string search scheme defined in matcher_avx512bw.cpp

std::vector<size_t>& reflex::Matcher::stops | ( |  | ) |
| inline

Returns reference to vector of current indent stop positions.

Returns
  vector of size_t

## Member Data Documentation

bool(Matcher::* reflex::Matcher::adv_) (size_t loc)
| protected

advance FIND function pointer

size_t reflex::Matcher::col_
| protected

column counter for indent matching, updated by newline(), indent(), and dedent()

size_t reflex::Matcher::ded_
| protected

dedent count

FSM reflex::Matcher::fsm_
| protected

local state for FSM code

std::vector<int> reflex::Matcher::lap_
| protected

lookahead position in input that heads a lookahead match (indexed by lookahead number)

bool reflex::Matcher::mrk_
| protected

indent or dedent in pattern found: should check and update indent stops

std::stack<Stops> reflex::Matcher::stk_
| protected

stack to push/pop stops

Stops reflex::Matcher::tab_
| protected

tab stops set by detecting indent margins

The documentation for this class was generated from the following file:

- matcher.h