reflex::Matcher Class Reference

updated Tue Nov 15 2016
 
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
reflex::Matcher Class Reference

#include <matcher.h>

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

Public Member Functions

template<typename P >
 Matcher (const P &pat, const Input &inp=Input(), const char *opt=NULL)
 Construct matcher engine from a pattern or a string regex, and an input character sequence. More...
 
template<typename P >
 Matcher (const P *pat, const Input &inp=Input(), const char *opt=NULL)
 Construct matcher engine from a pattern or a string regex, and an input character sequence. More...
 
virtual void reset (const char *opt=NULL)
 Reset this matcher's state to the initial state. More...
 
- Public Member Functions inherited from reflex::PatternMatcher< reflex::Pattern >
 PatternMatcher (const PatternMatcher &matcher)
 Copy constructor. More...
 
virtual ~PatternMatcher ()
 Delete matcher, deletes pattern when owned, deletes this matcher's internal buffer. More...
 
virtual PatternMatcherpattern (const Pattern &pat)
 
virtual PatternMatcherpattern (const char *regex)
 
virtual PatternMatcherpattern (const std::string &regex)
 
const Patternpattern (void) const
 
- Public Member Functions inherited from reflex::AbstractMatcher
bool buffer (size_t blk=0)
 
void interactive (void)
 
void flush (void)
 Flush the buffer's remaining content. More...
 
virtual AbstractMatcherinput (const Input &inp)
 
size_t matches (void)
 
size_t accept (void) const
 
const char * text (void) const
 
size_t size (void) const
 
size_t lineno (void) const
 
size_t columno (void) const
 
std::pair< size_t, std::string > pair () const
 
size_t first (void) const
 
size_t last (void) const
 
bool at_bob (void) const
 
bool at_end (void)
 
bool hit_end (void) const
 
void set_end (bool eof)
 Set and force the end of input state. More...
 
bool at_bol (void) const
 
void set_bol (bool bol)
 Set the begin of a new line state. More...
 
int input (void)
 
void unput (char c)
 Put back one character on the input character sequence, invalidating current match info and text. More...
 
const char * rest (void)
 
void more (void)
 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
 
 operator std::string () const
 
 operator std::pair< size_t, std::string > () const
 
bool operator== (const char *rhs) const
 < rhs string to compare to More...
 
bool operator== (const std::string &rhs) const
 < rhs string to compare to More...
 
bool operator== (size_t rhs) const
 < capture index to compare accept() to More...
 
bool operator== (int rhs) const
 < capture index to compare accept() to More...
 
bool operator!= (const char *rhs) const
 < rhs string to compare to More...
 
bool operator!= (const std::string &rhs) const
 < rhs string to compare to More...
 
bool operator!= (size_t rhs) const
 < capture index to compare accept() to More...
 
bool operator!= (int rhs) const
 < capture index to compare accept() to More...
 

Protected Member Functions

virtual size_t match (Method method)
 
void newline (size_t &col)
 Update indentation column counter for indent() and dedent(). More...
 
bool indent (size_t &col)
 
bool dedent (size_t &col)
 
- Protected Member Functions inherited from reflex::PatternMatcher< reflex::Pattern >
 PatternMatcher (const Pattern &pat, const Input &inp=Input(), const char *opt=NULL)
 Construct a base abstract matcher from a pattern object and an input character sequence. More...
 
 PatternMatcher (const Pattern *pat, const Input &inp=Input(), const char *opt=NULL)
 Construct a base abstract matcher from a pattern object pointer and an input character sequence. More...
 
 PatternMatcher (const char *regex, const Input &inp=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 &regex, const Input &inp=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
 AbstractMatcher (const Input &inp, const char *opt)
 Construct a base abstract matcher. More...
 
void init (const char *opt)
 Initialize the base abstract matcher at construction. More...
 
virtual size_t get (char *s, size_t n)
 
virtual bool wrap (void)
 
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. More...
 
int get (void)
 
int peek (void)
 
void set_current (size_t loc)
 Set the current position to advance to the next match. More...
 

Protected Attributes

size_t ded_
 dedent count More...
 
std::vector< size_t > 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...
 
- Protected Attributes inherited from reflex::PatternMatcher< reflex::Pattern >
bool own_
 true if PatternMatcher::pat_ was internally allocated More...
 
const Patternpat_
 points to the pattern object used by the matcher More...
 
- Protected Attributes inherited from reflex::AbstractMatcher
Option opt_
 options for matcher engines More...
 
char * buf_
 input character sequence buffer More...
 
const 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_ immediately 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_
 indent margin 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::buf_[AbstractMatcher::pos_] More...
 
size_t lno_
 line number count (prior to this buffered input) More...
 
size_t cno_
 column number count (prior to this buffered input) More...
 
size_t num_
 character count (number of characters flushed prior to this buffered input) More...
 
bool eof_
 input has reached EOF More...
 
bool mat_
 true if AbstractMatcher::matches() was successful 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< AbstractMatcheriterator
 std::input_iterator for scanning, searching, and splitting input character sequences More...
 
typedef AbstractMatcher::Iterator< const AbstractMatcherconst_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...
 
- Protected Types inherited from reflex::AbstractMatcher
typedef int Method
 

Detailed Description

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

Constructor & Destructor Documentation

template<typename P >
reflex::Matcher::Matcher ( const P &  pat,
const Input inp = Input(),
const char *  opt = NULL 
)
inline

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

<

Template Parameters
<P>a reflex::Pattern or a string regex
Parameters
pata reflex::Pattern or a string regex for this matcher
inpinput character sequence for this matcher
optoption string of the form (A|N|T(=[[:digit:]])?|;)*
template<typename P >
reflex::Matcher::Matcher ( const P *  pat,
const Input inp = Input(),
const char *  opt = NULL 
)
inline

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

<

Template Parameters
<P>a reflex::Pattern or a string regex
Parameters
patpoints to a reflex::Pattern or a string regex for this matcher
inpinput character sequence for this matcher
optoption string of the form (A|N|T(=[[:digit:]])?|;)*

Member Function Documentation

bool reflex::Matcher::dedent ( size_t &  col)
inlineprotected

Returns true if looking at dedent.

Returns
true if dedent.
Parameters
colindent column counter
bool reflex::Matcher::indent ( size_t &  col)
inlineprotected

Returns true if looking at indent.

Returns
true if indent.
Parameters
colindent column counter
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. Const::SCAN, Const::FIND, Const::SPLIT, or Const::MATCH

Implements reflex::AbstractMatcher.

void reflex::Matcher::newline ( size_t &  col)
inlineprotected

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

Parameters
colindent column counter
virtual void reflex::Matcher::reset ( const char *  opt = NULL)
inlinevirtual

Reset this matcher's state to the initial state.

Reimplemented from reflex::AbstractMatcher.

Member Data Documentation

size_t reflex::Matcher::ded_
protected

dedent count

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

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

std::vector<size_t> reflex::Matcher::tab_
protected

tab stops set by detecting indent margins


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