reflex::FlexLexer< M > Class Template Reference

updated Mon Apr 10 2017 by Robert van Engelen
 
Classes | Public Types | Public Member Functions | Protected 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 >:
Inheritance graph
[legend]
Collaboration diagram for reflex::FlexLexer< M >:
Collaboration graph
[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 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 output (char c)
 Output one 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...
 
- 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...
 
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 Member Functions

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...
 
void yy_push_state (int state, void *self=NULL)
 Push the current start condition state on the stack and transition to the given start condition state. More...
 
void yy_pop_state (void *self=NULL)
 Pop the stack start condition state and transition to that state. More...
 
int yy_top_state ()
 Returns the stack top start condition state. More...
 

Additional Inherited Members

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

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

More info TODO

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
inputinput to read from
osecho 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 character, returns zero when EOF.

Returns
the character read.
template<typename M >
virtual void reflex::FlexLexer< M >::LexerError ( const char *  s)
inlineprotectedvirtual

Invoked by reflex-generated yyFlexLexer when an error occurs.

Parameters
serror message
template<typename M >
virtual size_t reflex::FlexLexer< M >::LexerInput ( char *  s,
size_t  n 
)
inlineprotectedvirtual

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
spoints to the string buffer to fill with input
nsize of buffer pointed to by s
template<typename M >
virtual void reflex::FlexLexer< M >::LexerOutput ( const char *  s,
size_t  n 
)
inlineprotectedvirtual

Invoked by ECHO and FlexLexer::output.

Parameters
spoints to text to output
nlength of text to output
template<typename M >
void reflex::FlexLexer< M >::output ( char  c)
inline

Output one character.

Parameters
cchar 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
inputnew input to read from
osecho 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
ccharacter to put back
template<typename M >
void reflex::FlexLexer< M >::yy_pop_state ( void *  self = NULL)
inlineprotected

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

Parameters
selfreentrant or self
template<typename M >
void reflex::FlexLexer< M >::yy_push_state ( int  state,
void *  self = NULL 
)
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
selfreentrant or self
template<typename M >
int reflex::FlexLexer< M >::yy_top_state ( )
inlineprotected

Returns the stack top start condition state.

Returns
start condition (integer).
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: