File indexing completed on 2024-04-28 04:36:05

0001 
0002 // -*-C++-*-
0003 // FlexLexer.h -- define interfaces for lexical analyzer classes generated
0004 // by flex
0005 
0006 // Copyright (c) 1993 The Regents of the University of California.
0007 // All rights reserved.
0008 //
0009 // This code is derived from software contributed to Berkeley by
0010 // Kent Williams and Tom Epperly.
0011 //
0012 //  Redistribution and use in source and binary forms, with or without
0013 //  modification, are permitted provided that the following conditions
0014 //  are met:
0015 
0016 //  1. Redistributions of source code must retain the above copyright
0017 //  notice, this list of conditions and the following disclaimer.
0018 //  2. Redistributions in binary form must reproduce the above copyright
0019 //  notice, this list of conditions and the following disclaimer in the
0020 //  documentation and/or other materials provided with the distribution.
0021 
0022 //  Neither the name of the University nor the names of its contributors
0023 //  may be used to endorse or promote products derived from this software
0024 //  without specific prior written permission.
0025 
0026 //  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
0027 //  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
0028 //  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0029 //  PURPOSE.
0030 
0031 // This file defines FlexLexer, an abstract class which specifies the
0032 // external interface provided to flex C++ lexer objects, and yyFlexLexer,
0033 // which defines a particular lexer class.
0034 //
0035 // If you want to create multiple lexer classes, you use the -P flag
0036 // to rename each yyFlexLexer to some other xxFlexLexer.  You then
0037 // include <FlexLexer.h> in your other sources once per lexer class:
0038 //
0039 //  #undef yyFlexLexer
0040 //  #define yyFlexLexer xxFlexLexer
0041 //  #include <FlexLexer.h>
0042 //
0043 //  #undef yyFlexLexer
0044 //  #define yyFlexLexer zzFlexLexer
0045 //  #include <FlexLexer.h>
0046 //  ...
0047 
0048 #ifndef __FLEX_LEXER_H
0049 // Never included before - need to define base class.
0050 #define __FLEX_LEXER_H
0051 
0052 #include <iostream>
0053 #  ifndef FLEX_STD
0054 #    define FLEX_STD std::
0055 #  endif
0056 
0057 extern "C++" {
0058 
0059 struct yy_buffer_state;
0060 typedef int yy_state_type;
0061 
0062 class FlexLexer {
0063 public:
0064     virtual ~FlexLexer()    { }
0065 
0066     const char* YYText() const  { return yytext; }
0067     int YYLeng()    const   { return yyleng; }
0068 
0069     virtual void
0070         yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
0071     virtual struct yy_buffer_state*
0072         yy_create_buffer( FLEX_STD istream* s, int size ) = 0;
0073     virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
0074     virtual void yyrestart( FLEX_STD istream* s ) = 0;
0075 
0076     virtual int yylex() = 0;
0077 
0078     // Call yylex with new input/output sources.
0079     int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 )
0080         {
0081         switch_streams( new_in, new_out );
0082         return yylex();
0083         }
0084 
0085     // Switch to new input/output streams.  A nil stream pointer
0086     // indicates "keep the current one".
0087     virtual void switch_streams( FLEX_STD istream* new_in = 0,
0088                     FLEX_STD ostream* new_out = 0 ) = 0;
0089 
0090     int lineno() const      { return yylineno; }
0091 
0092     int debug() const       { return yy_flex_debug; }
0093     void set_debug( int flag )  { yy_flex_debug = flag; }
0094 
0095 protected:
0096     char* yytext;
0097     int yyleng;
0098     int yylineno;       // only maintained if you use %option yylineno
0099     int yy_flex_debug;  // only has effect with -d or "%option debug"
0100 };
0101 
0102 }
0103 #endif
0104 
0105 #if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
0106 // Either this is the first time through (yyFlexLexerOnce not defined),
0107 // or this is a repeated include to define a different flavor of
0108 // yyFlexLexer, as discussed in the flex man page.
0109 #define yyFlexLexerOnce
0110 
0111 extern "C++" {
0112 
0113 class yyFlexLexer : public FlexLexer {
0114 public:
0115     // arg_yyin and arg_yyout default to the cin and cout, but we
0116     // only make that assignment when initializing in yylex().
0117     yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 );
0118 
0119     virtual ~yyFlexLexer();
0120 
0121     void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
0122     struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size );
0123     void yy_delete_buffer( struct yy_buffer_state* b );
0124     void yyrestart( FLEX_STD istream* s );
0125 
0126     void yypush_buffer_state( struct yy_buffer_state* new_buffer );
0127     void yypop_buffer_state(void);
0128 
0129 #ifndef yywrap
0130     int yywrap();
0131 #endif
0132     virtual int yylex();
0133     virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out );
0134 
0135 protected:
0136     virtual int LexerInput( char* buf, int max_size );
0137     virtual void LexerOutput( const char* buf, int size );
0138     virtual void LexerError( const char* msg );
0139 
0140     void yyunput( int c, char* buf_ptr );
0141     int yyinput();
0142 
0143     void yy_load_buffer_state();
0144     void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s );
0145     void yy_flush_buffer( struct yy_buffer_state* b );
0146 
0147     int yy_start_stack_ptr;
0148     int yy_start_stack_depth;
0149     int* yy_start_stack;
0150 
0151     void yy_push_state( int new_state );
0152     void yy_pop_state();
0153     int yy_top_state();
0154 
0155     yy_state_type yy_get_previous_state();
0156     yy_state_type yy_try_NUL_trans( yy_state_type current_state );
0157     int yy_get_next_buffer();
0158 
0159     FLEX_STD istream* yyin; // input source for default LexerInput
0160     FLEX_STD ostream* yyout;    // output sink for default LexerOutput
0161 
0162     // yy_hold_char holds the character lost when yytext is formed.
0163     char yy_hold_char;
0164 
0165     // Number of characters read into yy_ch_buf.
0166     int yy_n_chars;
0167 
0168     // Points to current character in buffer.
0169     char* yy_c_buf_p;
0170 
0171     int yy_init;        // whether we need to initialize
0172     int yy_start;       // start state number
0173 
0174     // Flag which is used to allow yywrap()'s to do buffer switches
0175     // instead of setting up a fresh yyin.  A bit of a hack ...
0176     int yy_did_buffer_switch_on_eof;
0177 
0178 
0179     size_t yy_buffer_stack_top; /**< index of top of stack. */
0180     size_t yy_buffer_stack_max; /**< capacity of stack. */
0181     struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
0182     void yyensure_buffer_stack(void);
0183 
0184     // The following are not always needed, but may be depending
0185     // on use of certain flex features (like REJECT or yymore()).
0186 
0187     yy_state_type yy_last_accepting_state;
0188     char* yy_last_accepting_cpos;
0189 
0190     yy_state_type* yy_state_buf;
0191     yy_state_type* yy_state_ptr;
0192 
0193     char* yy_full_match;
0194     int* yy_full_state;
0195     int yy_full_lp;
0196 
0197     int yy_lp;
0198     int yy_looking_for_trail_begin;
0199 
0200     int yy_more_flag;
0201     int yy_more_len;
0202     int yy_more_offset;
0203     int yy_prev_more_offset;
0204 };
0205 
0206 }
0207 
0208 #endif