FlexLexer.h

Go to the documentation of this file.
00001 // /usr/local/src/Master//debian/flex/FlexLexer.h,v 1.3 2003/03/21 06:59:26 srivasta Exp
00002 
00003 // FlexLexer.h -- define interfaces for lexical analyzer classes generated
00004 //                by flex
00005 
00006 // Copyright (c) 1993 The Regents of the University of California.
00007 // All rights reserved.
00008 //
00009 // This code is derived from software contributed to Berkeley by
00010 // Kent Williams and Tom Epperly.
00011 //
00012 // Redistribution and use in source and binary forms with or without
00013 // modification are permitted provided that: (1) source distributions retain
00014 // this entire copyright notice and comment, and (2) distributions including
00015 // binaries display the following acknowledgement:  ``This product includes
00016 // software developed by the University of California, Berkeley and its
00017 // contributors'' in the documentation or other materials provided with the
00018 // distribution and in all advertising materials mentioning features or use
00019 // of this software.  Neither the name of the University nor the names of
00020 // its contributors may be used to endorse or promote products derived from
00021 // this software without specific prior written permission.
00022 
00023 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
00024 // WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00025 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00026 
00027 // This file defines FlexLexer, an abstract class which specifies the
00028 // external interface provided to flex C++ lexer objects, and yyFlexLexer,
00029 // which defines a particular lexer class.
00030 //
00031 // If you want to create multiple lexer classes, you use the -P flag
00032 // to rename each yyFlexLexer to some other xxFlexLexer.  You then
00033 // include <FlexLexer.h> in your other sources once per lexer class:
00034 //
00035 //      #undef yyFlexLexer
00036 //      #define yyFlexLexer xxFlexLexer
00037 //      #include <FlexLexer.h>
00038 //
00039 //      #undef yyFlexLexer
00040 //      #define yyFlexLexer zzFlexLexer
00041 //      #include <FlexLexer.h>
00042 //      ...
00043 
00044 #ifndef __FLEX_LEXER_H
00045 // Never included before - need to define base class.
00046 #define __FLEX_LEXER_H
00047 #include <iostream>
00048 
00049 extern "C++" {
00050 
00051 struct yy_buffer_state;
00052 typedef int yy_state_type;
00053 
00054 class FlexLexer {
00055 public:
00056         virtual ~FlexLexer()    { }
00057 
00058         const char* YYText()    { return yytext; }
00059         int YYLeng()            { return yyleng; }
00060 
00061         virtual void
00062                 yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
00063         virtual struct yy_buffer_state*
00064                 yy_create_buffer( std::istream* s, int size ) = 0;
00065         virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
00066         virtual void yyrestart( std::istream* s ) = 0;
00067 
00068         virtual int yylex() = 0;
00069 
00070         // Call yylex with new input/output sources.
00071         int yylex( std::istream* new_in, std::ostream* new_out = 0 )
00072                 {
00073                 switch_streams( new_in, new_out );
00074                 return yylex();
00075                 }
00076 
00077         // Switch to new input/output streams.  A nil stream pointer
00078         // indicates "keep the current one".
00079         virtual void switch_streams( std::istream* new_in = 0,
00080                                         std::ostream* new_out = 0 ) = 0;
00081 
00082         int lineno() const              { return yylineno; }
00083 
00084         int debug() const               { return yy_flex_debug; }
00085         void set_debug( int flag )      { yy_flex_debug = flag; }
00086 
00087 protected:
00088         char* yytext;
00089         int yyleng;
00090         int yylineno;           // only maintained if you use %option yylineno
00091         int yy_flex_debug;      // only has effect with -d or "%option debug"
00092 };
00093 
00094 }
00095 #endif
00096 
00097 #if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
00098 // Either this is the first time through (yyFlexLexerOnce not defined),
00099 // or this is a repeated include to define a different flavor of
00100 // yyFlexLexer, as discussed in the flex man page.
00101 #define yyFlexLexerOnce
00102 
00103 class yyFlexLexer : public FlexLexer {
00104 public:
00105         // arg_yyin and arg_yyout default to the cin and cout, but we
00106         // only make that assignment when initializing in yylex().
00107         yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 );
00108 
00109         virtual ~yyFlexLexer();
00110 
00111         void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
00112         struct yy_buffer_state* yy_create_buffer( std::istream* s, int size );
00113         void yy_delete_buffer( struct yy_buffer_state* b );
00114         void yyrestart( std::istream* s );
00115 
00116         virtual int yylex();
00117         virtual void switch_streams( std::istream* new_in, std::ostream* new_out );
00118 
00119 protected:
00120         virtual int LexerInput( char* buf, int max_size );
00121         virtual void LexerOutput( const char* buf, int size );
00122         virtual void LexerError( const char* msg );
00123 
00124         void yyunput( int c, char* buf_ptr );
00125         int yyinput();
00126 
00127         void yy_load_buffer_state();
00128         void yy_init_buffer( struct yy_buffer_state* b, std::istream* s );
00129         void yy_flush_buffer( struct yy_buffer_state* b );
00130 
00131         int yy_start_stack_ptr;
00132         int yy_start_stack_depth;
00133         int* yy_start_stack;
00134 
00135         void yy_push_state( int new_state );
00136         void yy_pop_state();
00137         int yy_top_state();
00138 
00139         yy_state_type yy_get_previous_state();
00140         yy_state_type yy_try_NUL_trans( yy_state_type current_state );
00141         int yy_get_next_buffer();
00142 
00143         std::istream* yyin;     // input source for default LexerInput
00144         std::ostream* yyout;    // output sink for default LexerOutput
00145 
00146         struct yy_buffer_state* yy_current_buffer;
00147 
00148         // yy_hold_char holds the character lost when yytext is formed.
00149         char yy_hold_char;
00150 
00151         // Number of characters read into yy_ch_buf.
00152         int yy_n_chars;
00153 
00154         // Points to current character in buffer.
00155         char* yy_c_buf_p;
00156 
00157         int yy_init;            // whether we need to initialize
00158         int yy_start;           // start state number
00159 
00160         // Flag which is used to allow yywrap()'s to do buffer switches
00161         // instead of setting up a fresh yyin.  A bit of a hack ...
00162         int yy_did_buffer_switch_on_eof;
00163 
00164         // The following are not always needed, but may be depending
00165         // on use of certain flex features (like REJECT or yymore()).
00166 
00167         yy_state_type yy_last_accepting_state;
00168         char* yy_last_accepting_cpos;
00169 
00170         yy_state_type* yy_state_buf;
00171         yy_state_type* yy_state_ptr;
00172 
00173         char* yy_full_match;
00174         int* yy_full_state;
00175         int yy_full_lp;
00176 
00177         int yy_lp;
00178         int yy_looking_for_trail_begin;
00179 
00180         int yy_more_flag;
00181         int yy_more_len;
00182         int yy_more_offset;
00183         int yy_prev_more_offset;
00184 };
00185 
00186 #endif

Generated on Fri Jun 6 22:21:09 2008 for CrocoPat by  doxygen 1.5.1