reflex::FlexLexer< M > Class Template Reference

updated Fri Dec 9 2016
 
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | 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::Matcher for Flex-compatibility. More...
 

Public Member Functions

 FlexLexer (const Input &input=stdin, std::ostream *os=NULL)
 Construct Flex-compatible lexer to read from a std::istream (and echo the text matches to a std::ostream). More...
 
const char * YYText (void) const
 The matched text. More...
 
size_t YYLeng (void) const
 The matched text length. More...
 
void yy_switch_to_buffer (Matcher *m)
 Switch to another matcher (and use its buffer). More...
 
Matcheryy_create_buffer (const Input &input, int)
 Instantiate a new FlexLexer::Matcher and buffer. More...
 
void yy_delete_buffer (Matcher *m)
 Delete a matcher. More...
 
void yyrestart (const Input &input)
 Restart reading from a stream. More...
 
void yypush_buffer_state (Matcher *m)
 Push the current matcher on the stack and use a new matcher for scanning. More...
 
void yypop_buffer_state (void)
 Pop matcher from the stack and delete the current matcher. More...
 
virtual void switch_streams (const Input &input=stdin, std::ostream *os=&std::cout)
 Switch input and output streams. More...
 
int lineno (void) const
 Line number of matched text. More...
 
virtual int yywrap (void)
 Default yywrap operation at EOF: do not wrap input. More...
 
virtual int yylex (void)=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 (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

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...
 
int yyinput (void)
 Read one character, returns zero when EOF. More...
 
int input (void)
 Read one character, returns zero when EOF. More...
 
void unput (char c)
 Put one character back onto the input stream to be read again. More...
 
void output (char c)
 Output one character. More...
 
void yymore (void)
 Append the next matched text to the currently matched text. More...
 
void yyless (int n)
 Truncate the yytext length of the match to n characters in length and reposition for next match. 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 (void)
 Returns the stack top start condition state. More...
 
- Protected Member Functions inherited from reflex::AbstractLexer< M >
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

YY_EXTRA_TYPE yyextra
 Flex-compatible reentrant YY_EXTRA_TYPE yyextra. More...
 
- 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

Constructor & Destructor Documentation

template<typename M >
reflex::FlexLexer< M >::FlexLexer ( const Input input = stdin,
std::ostream *  os = NULL 
)
inline

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

Parameters
inputstd::istream (stdin by default) to read a character sequence from
osecho the text matches to this std::ostream (std::cout by default)

Member Function Documentation

template<typename M >
int reflex::FlexLexer< M >::input ( void  )
inlineprotected

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.

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 >
int reflex::FlexLexer< M >::lineno ( void  ) const
inline

Line number of matched text.

template<typename M >
void reflex::FlexLexer< M >::output ( char  c)
inlineprotected

Output one character.

Parameters
cchar to output via LexerOutput
template<typename M >
virtual void reflex::FlexLexer< M >::switch_streams ( const Input input = stdin,
std::ostream *  os = &std::cout 
)
inlinevirtual

Switch input and output streams.

Parameters
inputinput to read from
osecho the text matches to this std::ostream
template<typename M >
void reflex::FlexLexer< M >::unput ( char  c)
inlineprotected

Put one character back onto the input stream to be read again.

Parameters
cchar to put back onto the input stream
template<typename M >
Matcher* reflex::FlexLexer< M >::yy_create_buffer ( const Input input,
int   
)
inline

Instantiate a new FlexLexer::Matcher and buffer.

Returns
pointer to new FlexLexer::Matcher.
Parameters
inputread from an input source
template<typename M >
void reflex::FlexLexer< M >::yy_delete_buffer ( Matcher m)
inline

Delete a matcher.

Parameters
mvictim to delete
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 >
void reflex::FlexLexer< M >::yy_switch_to_buffer ( Matcher m)
inline

Switch to another matcher (and use its buffer).

Parameters
mthe matcher to switch to
template<typename M >
int reflex::FlexLexer< M >::yy_top_state ( void  )
inlineprotected

Returns the stack top start condition state.

Returns
start condition (integer).
template<typename M >
int reflex::FlexLexer< M >::yyinput ( void  )
inlineprotected

Read one character, returns zero when EOF.

Returns
the character read.
template<typename M >
size_t reflex::FlexLexer< M >::YYLeng ( void  ) const
inline

The matched text length.

Returns
matched text length.
template<typename M >
void reflex::FlexLexer< M >::yyless ( int  n)
inlineprotected

Truncate the yytext length of the match to n characters in length and reposition for next match.

Parameters
ntruncated string length
template<typename M >
virtual int reflex::FlexLexer< M >::yylex ( void  )
pure virtual

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

template<typename M >
void reflex::FlexLexer< M >::yymore ( void  )
inlineprotected

Append the next matched text to the currently matched text.

template<typename M >
void reflex::FlexLexer< M >::yypop_buffer_state ( void  )
inline

Pop matcher from the stack and delete the current matcher.

template<typename M >
void reflex::FlexLexer< M >::yypush_buffer_state ( Matcher m)
inline

Push the current matcher on the stack and use a new matcher for scanning.

Parameters
mnew FlexLexer::Matcher for scanning
template<typename M >
void reflex::FlexLexer< M >::yyrestart ( const Input input)
inline

Restart reading from a stream.

Parameters
inputread from an input source
template<typename M >
const char* reflex::FlexLexer< M >::YYText ( void  ) const
inline

The matched text.

Returns
NUL-terminated string.
template<typename M >
virtual int reflex::FlexLexer< M >::yywrap ( void  )
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).

Member Data Documentation

template<typename M >
YY_EXTRA_TYPE reflex::FlexLexer< M >::yyextra
protected

Flex-compatible reentrant YY_EXTRA_TYPE yyextra.


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