reflex::AbstractLexer< M > Class Template Reference

updated Mon Apr 10 2017 by Robert van Engelen
 
Classes | Public Member Functions | Protected Attributes | List of all members
reflex::AbstractLexer< M > Class Template Reference

The abstract lexer class template that is the abstract root class of all reflex-generated scanners. More...

#include <abslexer.h>

Inheritance diagram for reflex::AbstractLexer< M >:
Inheritance graph
[legend]
Collaboration diagram for reflex::AbstractLexer< M >:
Collaboration graph
[legend]

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...
 
AbstractLexerin (const Input &input)
 Reset the matcher and start scanning from the given input character sequence. More...
 
Inputin ()
 Returns the current input character sequence that is being scanned. More...
 
Inputstdinit ()
 Returns the current input character sequence that is being scanned, if none assign stdin. More...
 
Inputnostdinit ()
 Returns the current input character sequence that is being scanned, if none assign std::cin. More...
 
AbstractLexerout (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...
 
bool has_matcher () const
 Returns true if a matcher was assigned to this lexer for scanning. More...
 
AbstractLexermatcher (Matcher *matcher)
 Set the matcher (and its current state) for scanning. More...
 
Matchermatcher () const
 Returns a reference to the current matcher. More...
 
Matcherptr_matcher () const
 Returns a pointer to the current matcher, NULL if none was set. More...
 
virtual Matchernew_matcher (const Input &input)
 Returns a new 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...
 
void 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 string with the text matched. More...
 
std::string str () const
 Returns string with a copy of the text matched. More...
 
std::wstring wstr () const
 Returns wide string with a copy 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...
 
size_t columno () const
 Returns the column number of matched text, counting wide characters. More...
 
AbstractLexerstart (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. More...
 

Protected Attributes

Matchermatcher_
 the matcher used for scanning More...
 
Input in_
 the input character sequence to scan More...
 
std::ostream * os_
 the output stream to echo text matches to 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...
 

Detailed Description

template<typename M>
class reflex::AbstractLexer< M >

The abstract lexer class template that is the abstract root class of all reflex-generated scanners.

More info TODO

Template Parameters
<M>matcher class derived from reflex::AbstractMatcher

Constructor & Destructor Documentation

template<typename M >
reflex::AbstractLexer< M >::AbstractLexer ( const Input input,
std::ostream &  os 
)
inline

Construct abstract lexer to scan an input character sequence and echo the text matches to output.

Parameters
inputreflex::Input character sequence to read from
osecho the text matches to this std::ostream or to std::cout
template<typename M >
virtual reflex::AbstractLexer< M >::~AbstractLexer ( )
inlinevirtual

Delete lexer and its current matcher with its associated input.

Member Function Documentation

template<typename M >
size_t reflex::AbstractLexer< M >::columno ( ) const
inline

Returns the column number of matched text, counting wide characters.

Returns
column number.
template<typename M >
virtual int reflex::AbstractLexer< M >::debug ( ) const
inlinevirtual

Get debug flag value.

Returns
debug flag value.
template<typename M >
void reflex::AbstractLexer< M >::del_matcher ( Matcher matcher)
inline

Delete a matcher.

template<typename M >
void reflex::AbstractLexer< M >::echo ( ) const
inline

Echo the matched text to the current output.

template<typename M >
bool reflex::AbstractLexer< M >::has_matcher ( ) const
inline

Returns true if a matcher was assigned to this lexer for scanning.

Returns
true if a matcher was assigned.
template<typename M >
AbstractLexer& reflex::AbstractLexer< M >::in ( const Input input)
inline

Reset the matcher and start scanning from the given input character sequence.

Returns
reference to *this.
Parameters
inputreflex::Input character sequence to scan
template<typename M >
Input& reflex::AbstractLexer< M >::in ( )
inline

Returns the current input character sequence that is being scanned.

Returns
reference to the current reflex::Input object.
template<typename M >
size_t reflex::AbstractLexer< M >::lineno ( ) const
inline

Returns the line number of matched text.

Returns
line number.
template<typename M >
AbstractLexer& reflex::AbstractLexer< M >::matcher ( Matcher matcher)
inline

Set the matcher (and its current state) for scanning.

Returns
reference to *this.
Parameters
matcherpoints to a matcher object
template<typename M >
Matcher& reflex::AbstractLexer< M >::matcher ( ) const
inline

Returns a reference to the current matcher.

Returns
reference to the current matcher.
template<typename M >
virtual Matcher* reflex::AbstractLexer< M >::new_matcher ( const Input input)
inlinevirtual

Returns a new matcher for the given input.

Returns
pointer to new reflex::AbstractLexer::Matcher.
Parameters
inputreflex::Input character sequence to match
template<typename M >
Input& reflex::AbstractLexer< M >::nostdinit ( )
inline

Returns the current input character sequence that is being scanned, if none assign std::cin.

Returns
reference to the current reflex::Input object with input assigned.
template<typename M >
AbstractLexer& reflex::AbstractLexer< M >::out ( std::ostream &  os)
inline

Set the current output to the given output stream to echo text matches to.

Returns
reference to *this.
Parameters
osoutput stream to echo text matches to
template<typename M >
std::ostream& reflex::AbstractLexer< M >::out ( ) const
inline

Returns the current output stream used to echo text matches to.

Returns
reference to the current std::ostream object.
template<typename M >
void reflex::AbstractLexer< M >::perf_report ( )
inline

Dummy performance reporter, to prevent link errors when reflex option -p is omitted.

template<typename M >
void reflex::AbstractLexer< M >::pop_matcher ( )
inline

Pop matcher from the stack and continue scanning where it left off, delete the current matcher.

template<typename M >
void reflex::AbstractLexer< M >::pop_state ( )
inline

Pop the stack start condition state and transition to that state.

template<typename M >
Matcher* reflex::AbstractLexer< M >::ptr_matcher ( ) const
inline

Returns a pointer to the current matcher, NULL if none was set.

Returns
pointer to the current matcher or NULL if no matcher was set.
template<typename M >
void reflex::AbstractLexer< M >::push_matcher ( Matcher matcher)
inline

Push the current matcher on the stack and use the given matcher for scanning.

Parameters
matcherpoints to a matcher object
template<typename M >
void reflex::AbstractLexer< M >::push_state ( int  state)
inline

Push the current start condition state on the stack and transition to the given start condition state.

Parameters
statestart condition state to transition to
template<typename M >
virtual void reflex::AbstractLexer< M >::set_debug ( int  flag)
inlinevirtual

Set debug flag value.

Parameters
flag0 or 1 (false or true)
template<typename M >
size_t reflex::AbstractLexer< M >::size ( ) const
inline

Returns the matched text size in number of bytes.

Returns
size of the matched text.
template<typename M >
AbstractLexer& reflex::AbstractLexer< M >::start ( int  state)
inline

Transition to the given start condition state.

Returns
reference to *this.
Parameters
statestart condition state to transition to
template<typename M >
int reflex::AbstractLexer< M >::start ( ) const
inline

Returns the current start condition state.

Returns
start condition (integer).
template<typename M >
Input& reflex::AbstractLexer< M >::stdinit ( )
inline

Returns the current input character sequence that is being scanned, if none assign stdin.

Returns
reference to the current reflex::Input object with input assigned.
template<typename M >
std::string reflex::AbstractLexer< M >::str ( ) const
inline

Returns string with a copy of the text matched.

Returns
matched text.
template<typename M >
const char* reflex::AbstractLexer< M >::text ( ) const
inline

Returns string with the text matched.

Returns
matched text.
template<typename M >
int reflex::AbstractLexer< M >::top_state ( ) const
inline

Returns the stack top start condition state.

Returns
start condition (integer).
template<typename M >
virtual int reflex::AbstractLexer< M >::wrap ( )
inlinevirtual

The default wrap operation at EOF: do not wrap input.

Returns
1 (override to return 0 to indicate that new input is available after this invocation so that wrap after EOF is OK).
template<typename M >
size_t reflex::AbstractLexer< M >::wsize ( ) const
inline

Returns the matched text size in number of (wide) characters.

Returns
number of (wide) characters matched.
template<typename M >
std::wstring reflex::AbstractLexer< M >::wstr ( ) const
inline

Returns wide string with a copy of the text matched.

Returns
matched text.

Member Data Documentation

template<typename M >
int reflex::AbstractLexer< M >::debug_
protected

1 if -d (–debug) 0 otherwise:

template<typename M >
Input reflex::AbstractLexer< M >::in_
protected

the input character sequence to scan

template<typename M >
Matcher* reflex::AbstractLexer< M >::matcher_
protected

the matcher used for scanning

template<typename M >
std::ostream* reflex::AbstractLexer< M >::os_
protected

the output stream to echo text matches to

template<typename M >
std::stack<Matcher*> reflex::AbstractLexer< M >::stack_
protected

a stack of pointers to matchers

template<typename M >
int reflex::AbstractLexer< M >::start_
protected

the current start condition state

template<typename M >
std::stack<int> reflex::AbstractLexer< M >::state_
protected

a stack of start condition states


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