|  | reflex::AbstractLexer< M > Class Template Reference updated Fri Dec 9 2016 |

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

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 >:
[legend]
Collaboration diagram for reflex::AbstractLexer< M >:
[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...
AbstractLexer & | in (const Input &input)
| Start scanning from the given input character sequence. More...
Input & | in (void)
| Returns the current input character sequence that is being scanned. More...
AbstractLexer & | out (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...
AbstractLexer & | matcher (Matcher *matcher)
| Set the matcher (and its current state) for scanning. More...
Matcher & | matcher (void) const
| Returns the current matcher. More...
virtual Matcher * | new_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
AbstractLexer & | start (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
Matcher * | matcher_
| 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

  input | reflex::Input character sequence to read from
  os | echo the text matches to this std::ostream or to std::cout

template<typename M >

virtual reflex::AbstractLexer< M >::~AbstractLexer | ( | void |  | ) |
| inline virtual

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
| inline virtual

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

  input | reflex::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

  matcher | points 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 | ) |
| inline virtual

Returns a new matcher for the given input.

Returns
  pointer to new reflex::AbstractLexer::Matcher.

Parameters

  input | reflex::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

  os | output 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 |  | ) |
| inline protected

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

  matcher | points to a matcher object

template<typename M >

void reflex::AbstractLexer< M >::push_state | ( | int | state | ) |
| inline protected

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

Parameters

  state | start condition state to transition to

template<typename M >

virtual void reflex::AbstractLexer< M >::set_debug | ( | int | flag | ) |
| inline virtual

Set debug flag value.

Parameters

  flag | 0 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 | ) |
| inline protected

Transition to the given start condition state.

Returns
  reference to *this.

Parameters

  state | start condition state to transition to

template<typename M >

int reflex::AbstractLexer< M >::start | ( | void |  | ) | const
| inline protected

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
| inline protected

Returns the stack top start condition state.

Returns
  start condition (integer).

template<typename M >

virtual int reflex::AbstractLexer< M >::wrap | ( | void |  | ) |
| inline virtual

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:

- abslexer.h