|  | reflex::FlexLexer< M > Class Template Reference updated Sun Nov 5 2023 by Robert van Engelen |

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | List of all members
reflex::FlexLexer< M > Class Template Referenceabstract

Flex-compatible FlexLexer abstract base class template derived from reflex::AbstractMatcher for the reflex-generated yyFlexLexer scanner class. More...

`#include <flexlexer.h>`

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

## Classes

class | Matcher
| Extends reflex::AbstractLexer<M>::Matcher for Flex-compatibility. More...

## Public Types

typedef AbstractLexer< M > | AbstractBaseLexer
| Typedef for the abstract base class. More...

## Public Member Functions

| FlexLexer (const Input &input, std::ostream *os)
| Construct Flex-compatible lexer to read from a std::istream (and echo the text matches to a std::ostream). More...
const char * | YYText () const
| The matched text. More...
int | YYLeng () const
| The matched text length. More...
int | input ()
| Read one 8-bit character, returns zero when EOF. More...
int | winput ()
| Read one wide character, returns zero when EOF. More...
void | unput (char c)
| Put back one character on the input character sequence for matching, invalidating the current match info and text. More...
void | unput (int c)
| Put back one wide character on the input character sequence for matching, invalidating the current match info and text. More...
void | output (char c)
| Output one character. More...
void | woutput (int c)
| Output one wide character. More...
virtual void | switch_streams (const Input &input=Input(), std::ostream *os=NULL)
| Switch input and output streams. More...
virtual int | yywrap ()
| Default yywrap operation at EOF: do not wrap input. More...
virtual int | yylex ()=0
| Pure virtual lexer (implemented by a reflex-generated yyFlexLexer). More...
virtual size_t | LexerInput (char *s, size_t n)
| Invoked by FlexLexer::Matcher to read input character sequence. More...
virtual void | LexerOutput (const char *s, size_t n)
| Invoked by ECHO and FlexLexer::output. More...
virtual void | LexerError (const char *s)
| Invoked by reflex-generated yyFlexLexer when an error occurs. More...
Public Member Functions inherited from reflex::AbstractLexer< M >
| 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 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...
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...

## Additional Inherited Members

Protected Attributes inherited from reflex::AbstractLexer< M >
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...

## Detailed Description

### template<typename M>
class reflex::FlexLexer< M >

Flex-compatible FlexLexer abstract base class template derived from reflex::AbstractMatcher for the reflex-generated yyFlexLexer scanner class.

Template Parameters

  <M> | matcher class derived from reflex::AbstractMatcher

## Member Typedef Documentation

template<typename M >

typedef AbstractLexer<M> reflex::FlexLexer< M >::AbstractBaseLexer

Typedef for the abstract base class.

## Constructor & Destructor Documentation

template<typename M >

reflex::FlexLexer< M >::FlexLexer | ( | const Input & | input,
|  | std::ostream * | os
| ) |  |

inline

Construct Flex-compatible lexer to read from a std::istream (and echo the text matches to a std::ostream).

Parameters

  input | input to read from
  os | echo the text matches to this std::ostream (std::cout by default)

## Member Function Documentation

template<typename M >

int reflex::FlexLexer< M >::input | ( |  | ) |

inline

Read one 8-bit character, returns zero when EOF.

Returns
  the character read.

template<typename M >

virtual void reflex::FlexLexer< M >::LexerError | ( | const char * | s | ) |

inlinevirtual

Invoked by reflex-generated yyFlexLexer when an error occurs.

Parameters

  s | error message

template<typename M >

virtual size_t reflex::FlexLexer< M >::LexerInput | ( | char * | s,
|  | size_t | n
| ) |  |

inlinevirtual

Invoked by FlexLexer::Matcher to read input character sequence.

Returns
  the nonzero number of (less or equal to n) 8-bit characters added to buffer s from the current input, or zero when EOF.

Parameters

  s | points to the string buffer to fill with input
  n | size of buffer pointed to by s

template<typename M >

virtual void reflex::FlexLexer< M >::LexerOutput | ( | const char * | s,
|  | size_t | n
| ) |  |

inlinevirtual

Invoked by ECHO and FlexLexer::output.

Parameters

  s | points to text to output
  n | length of text to output

template<typename M >

void reflex::FlexLexer< M >::output | ( | char | c | ) |

inline

Output one character.

Parameters

  c | 8-bit char to output via LexerOutput

template<typename M >

virtual void reflex::FlexLexer< M >::switch_streams | ( | const Input & | input = `Input()`,
|  | std::ostream * | os = `NULL`
| ) |  |

inlinevirtual

Switch input and output streams.

Parameters

  input | new input to read from
  os | echo the text matches to this std::ostream or std::cout by default

template<typename M >

void reflex::FlexLexer< M >::unput | ( | char | c | ) |

inline

Put back one character on the input character sequence for matching, invalidating the current match info and text.

Parameters

  c | 8-bit character to put back

template<typename M >

void reflex::FlexLexer< M >::unput | ( | int | c | ) |

inline

Put back one wide character on the input character sequence for matching, invalidating the current match info and text.

Parameters

  c | wide character to put back

template<typename M >

int reflex::FlexLexer< M >::winput | ( |  | ) |

inline

Read one wide character, returns zero when EOF.

Returns
  the character read.

template<typename M >

void reflex::FlexLexer< M >::woutput | ( | int | c | ) |

inline

Output one wide character.

Parameters

  c | wide char to output via LexerOutput

template<typename M >

int reflex::FlexLexer< M >::YYLeng | ( |  | ) | const

inline

The matched text length.

Returns
  matched text length.

template<typename M >

virtual int reflex::FlexLexer< M >::yylex | ( |  | ) |

pure virtual

Pure virtual lexer (implemented by a reflex-generated yyFlexLexer).

template<typename M >

const char* reflex::FlexLexer< M >::YYText | ( |  | ) | const

inline

The matched text.

Returns
  NUL-terminated string.

template<typename M >

virtual int reflex::FlexLexer< M >::yywrap | ( |  | ) |

inlinevirtual

Default yywrap operation at EOF: do not wrap input.

Returns
  1 (0 indicates that new input was set and wrap after EOF is OK).

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

- flexlexer.h