reflex::AbstractLexer< M > Class Template Reference

updated Fri Dec 9 2016
 
Classes | Public Member Functions | Protected 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 (void)
 Delete lexer and its current matcher and input. More...
 
virtual void set_debug (int flag)
 Set debug flag value. More...
 
virtual int debug (void) const
 Get debug flag value. More...
 
virtual int wrap (void)
 The default wrap operation at EOF: do not wrap input. More...
 
AbstractLexerin (const Input &input)
 Start scanning from the given input character sequence. More...
 
Inputin (void)
 Returns the current input character sequence that is being scanned. More...
 
AbstractLexerout (std::ostream &os)
 Set the current output to the given output stream to echo text matches to. More...
 
std::ostream & out (void) const
 Returns the current output stream used to echo text matches to. More...
 
bool has_matcher (void) 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 (void) const
 Returns the current matcher. More...
 
virtual Matchernew_matcher (const Input &input)
 Returns a new matcher for the given input. More...
 
void del_matcher (Matcher *matcher) const
 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 (void)
 Pop matcher from the stack and continue scanning where it left off, delete the current matcher. More...
 
void echo (void) const
 Echo the matched text to the current output. More...
 
const char * text (void) const
 Returns string with the text matched. More...
 
size_t size (void) const
 Matched text size (length in bytes). More...
 
size_t lineno (void) const
 Line number of matched text. More...
 
size_t columno (void) const
 Column number of matched text. More...
 

Protected Member Functions

AbstractLexerstart (int state)
 Transition to the given start condition state. More...
 
int start (void) 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 (void)
 Pop the stack start condition state and transition to that state. More...
 
int top_state (void) 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 ( void  )
inlinevirtual

Delete lexer and its current matcher and input.

Member Function Documentation

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

Column number of matched text.

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

Get debug flag value.

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

Delete a matcher.

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

Echo the matched text to the current output.

template<typename M >
bool reflex::AbstractLexer< M >::has_matcher ( void  ) 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

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 ( void  )
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 ( void  ) const
inline

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 ( void  ) const
inline

Returns 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 >
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 ( void  ) 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 >::pop_matcher ( void  )
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 ( void  )
inlineprotected

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

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)
inlineprotected

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
template<typename M >
size_t reflex::AbstractLexer< M >::size ( void  ) const
inline

Matched text size (length in bytes).

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

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 ( void  ) const
inlineprotected

Returns the current start condition state.

Returns
start condition (integer).
template<typename M >
const char* reflex::AbstractLexer< M >::text ( void  ) const
inline

Returns string with the text matched.

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

Returns the stack top start condition state.

Returns
start condition (integer).
template<typename M >
virtual int reflex::AbstractLexer< M >::wrap ( void  )
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).

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: