The abstract lexer class template that is the abstract root class of all reflex-generated scanners. More...
#include <abslexer.h>
Classes | |
class | Matcher |
Extend matcher class M with a member pointing to the instantiating lexer class. More... | |
Public Member Functions | |
AbstractLexer (const Input &input, std::ostream &os) | |
Construct abstract lexer to scan an input character sequence and echo the text matches to output. More... | |
virtual | ~AbstractLexer () |
Delete lexer and its current matcher with its associated input. More... | |
virtual void | set_debug (int flag) |
Set debug flag value. More... | |
virtual int | debug () const |
Get debug flag value. More... | |
void | perf_report () |
Dummy performance reporter, to prevent link errors when reflex option -p is omitted. More... | |
virtual int | wrap () |
The default wrap operation at EOF: do not wrap input. More... | |
template<typename I > | |
AbstractLexer & | in (const I &input) |
Reset the matcher and start scanning from the given input character sequence I. More... | |
AbstractLexer & | in (const char *b, size_t n) |
Reset the matcher and start scanning from the given byte sequence. More... | |
Input & | in () |
Returns the current input character sequence that is being scanned. More... | |
Input & | stdinit () |
Returns the current input character sequence that is being scanned, if none assign stdin. More... | |
Input & | nostdinit () |
Returns the current input character sequence that is being scanned, if none assign std::cin. More... | |
AbstractLexer & | buffer (char *base, size_t size) |
Reset the matcher and start scanning the given buffer containing 0-terminated character data (data may be modified). More... | |
AbstractLexer & | out (std::ostream &os) |
Set the current output to the given output stream to echo text matches to. More... | |
std::ostream & | out () const |
Returns the current output stream used to echo text matches to. More... | |
std::ostream *& | os () |
Returns pointer to the current output stream used to echo text matches to. More... | |
bool | has_matcher () const |
Returns true if a matcher was assigned to this lexer for scanning. More... | |
AbstractLexer & | matcher (Matcher *matcher) |
Set the matcher (and its current state) for scanning. More... | |
Matcher & | matcher () const |
Returns a reference to the current matcher. More... | |
Matcher * | ptr_matcher () const |
Returns a pointer to the current matcher, NULL if none was set. More... | |
virtual Matcher * | new_matcher (const Input &input=Input(), const char *opt=NULL) |
Returns a new copy of the matcher for the given input. More... | |
void | del_matcher (Matcher *matcher) |
Delete a matcher. More... | |
void | push_matcher (Matcher *matcher) |
Push the current matcher on the stack and use the given matcher for scanning. More... | |
bool | pop_matcher () |
Pop matcher from the stack and continue scanning where it left off, delete the current matcher. More... | |
void | echo () const |
Echo the matched text to the current output. More... | |
const char * | text () const |
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 pattern match 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... | |
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... | |
size_t | size () const |
Returns the matched text size in number of bytes. More... | |
size_t | wsize () const |
Returns the matched text size in number of (wide) characters. More... | |
size_t | lineno () const |
Returns the line number of matched text. More... | |
void | lineno (size_t n) |
Set or change the starting line number of the last match. More... | |
size_t | lines () const |
Returns the number of lines that the match spans. More... | |
size_t | lineno_end () const |
Returns the ending line number of matched text. More... | |
size_t | columno () const |
Returns the starting column number of matched text, taking tab spacing into account and counting wide characters as one character each. More... | |
size_t | columns () const |
Returns the number of columns of the last line (or the single line of matched text) in the matched text, taking tab spacing into account and counting wide characters as one character each. More... | |
size_t | columno_end () const |
Returns the ending column number of matched text, taking tab spacing into account and counting wide characters as one character each. More... | |
AbstractLexer & | start (int state) |
Transition to the given start condition state. More... | |
int | start () const |
Returns the current start condition state. More... | |
void | push_state (int state) |
Push the current start condition state on the stack and transition to the given start condition state. More... | |
void | pop_state () |
Pop the stack start condition state and transition to that state. More... | |
int | top_state () const |
Returns the stack top start condition state or 0 (INITIAL) if the stack is empty. More... | |
bool | states_empty () const |
Returns true if the condition state stack is empty. More... | |
virtual void | lexer_error (const char *message=NULL) |
Lexer exceptions. More... | |
Protected Attributes | |
Input | in_ |
the input character sequence to scan More... | |
std::ostream * | os_ |
the output stream to echo text matches to More... | |
char * | base_ |
the buffer to scan in place, if non-NULL More... | |
size_t | size_ |
the size of the buffer to scan in place, if nonzero More... | |
Matcher * | matcher_ |
the matcher used for scanning More... | |
int | start_ |
the current start condition state More... | |
int | debug_ |
1 if -d (–debug) 0 otherwise: More... | |
std::stack< Matcher * > | stack_ |
a stack of pointers to matchers More... | |
std::stack< int > | state_ |
a stack of start condition states More... | |
The abstract lexer class template that is the abstract root class of all reflex-generated scanners.
<M> | matcher class derived from reflex::AbstractMatcher |
|
inline |
Construct abstract lexer to scan an input character sequence and echo the text matches to output.
input | reflex::Input character sequence to read from |
os | echo the text matches to this std::ostream or to std::cout |
|
inlinevirtual |
Delete lexer and its current matcher with its associated input.
|
inline |
Reset the matcher and start scanning the given buffer containing 0-terminated character data (data may be modified).
base | base of the buffer containing 0-terminated character data |
size | nonzero size of the buffer |
|
inline |
Returns the first 8-bit character of the text matched.
|
inline |
Returns the starting column number of matched text, taking tab spacing into account and counting wide characters as one character each.
|
inline |
Returns the ending column number of matched text, taking tab spacing into account and counting wide characters as one character each.
|
inline |
Returns the number of columns of the last line (or the single line of matched text) in the matched text, taking tab spacing into account and counting wide characters as one character each.
|
inlinevirtual |
Get debug flag value.
|
inline |
Delete a matcher.
|
inline |
Echo the matched text to the current output.
|
inline |
Returns true if a matcher was assigned to this lexer for scanning.
|
inline |
Reset the matcher and start scanning from the given input character sequence I.
input | a character sequence to scan, e.g. reflex::Input, char*, wchar_t*, std::string, std::wstring, FILE*, std::istream |
|
inline |
Reset the matcher and start scanning from the given byte sequence.
b | the byte sequence to scan |
n | length of the byte sequence to scan |
|
inline |
Returns the current input character sequence that is being scanned.
|
inlinevirtual |
Lexer exceptions.
|
inline |
Returns the line number of matched text.
|
inline |
Set or change the starting line number of the last match.
|
inline |
Returns the ending line number of matched text.
|
inline |
Returns the number of lines that the match spans.
|
inline |
Set the matcher (and its current state) for scanning.
matcher | points to a matcher object |
|
inline |
Returns a reference to the current matcher.
|
inlinevirtual |
Returns a new copy of the matcher for the given input.
input | reflex::Input character sequence to match |
opt | options, if any |
|
inline |
Returns the current input character sequence that is being scanned, if none assign std::cin.
|
inline |
Returns pointer to the current output stream used to echo text matches to.
|
inline |
Set the current output to the given output stream to echo text matches to.
os | output stream to echo text matches to |
|
inline |
Returns the current output stream used to echo text matches to.
|
inline |
Dummy performance reporter, to prevent link errors when reflex option -p is omitted.
|
inline |
Pop matcher from the stack and continue scanning where it left off, delete the current matcher.
|
inline |
Pop the stack start condition state and transition to that state.
|
inline |
Returns a pointer to the current matcher, NULL if none was set.
|
inline |
Push the current matcher on the stack and use the given matcher for scanning.
matcher | points to a matcher object |
|
inline |
Push the current start condition state on the stack and transition to the given start condition state.
state | start condition state to transition to |
|
inlinevirtual |
Set debug flag value.
flag | 0 or 1 (false or true) |
|
inline |
Returns the matched text size in number of bytes.
|
inline |
Transition to the given start condition state.
state | start condition state to transition to |
|
inline |
Returns the current start condition state.
|
inline |
Returns true if the condition state stack is empty.
|
inline |
Returns the current input character sequence that is being scanned, if none assign stdin.
|
inline |
Returns the pattern match as a string, a copy of text(), may include pattern-matched \0s.
|
inline |
Returns 0-terminated pattern match as a char pointer, does not include matched \0s, this is a constant-time operation.
|
inline |
Returns the stack top start condition state or 0 (INITIAL) if the stack is empty.
|
inline |
Returns the first wide character of the text matched.
|
inlinevirtual |
The default wrap operation at EOF: do not wrap input.
|
inline |
Returns the matched text size in number of (wide) characters.
|
inline |
Returns the pattern match as a wide string, converted from UTF-8 text(), may include pattern-matched \0s.
|
protected |
the buffer to scan in place, if non-NULL
|
protected |
1 if -d (–debug) 0 otherwise:
|
protected |
the input character sequence to scan
|
protected |
the matcher used for scanning
|
protected |
the output stream to echo text matches to
|
protected |
the size of the buffer to scan in place, if nonzero
|
protected |
a stack of pointers to matchers
|
protected |
the current start condition state
|
protected |
a stack of start condition states