[BACK]Return to FlexLexer.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / lex

Diff for /src/usr.bin/lex/FlexLexer.h between version 1.6 and 1.7

version 1.6, 2004/02/03 21:20:17 version 1.7, 2015/11/19 19:43:40
Line 2 
Line 2 
   
 // $Header$  // $Header$
   
   // -*-C++-*-
 // FlexLexer.h -- define interfaces for lexical analyzer classes generated  // FlexLexer.h -- define interfaces for lexical analyzer classes generated
 //                by flex  // by flex
   
 // Copyright (c) 1993 The Regents of the University of California.  // Copyright (c) 1993 The Regents of the University of California.
 // All rights reserved.  // All rights reserved.
Line 11 
Line 12 
 // This code is derived from software contributed to Berkeley by  // This code is derived from software contributed to Berkeley by
 // Kent Williams and Tom Epperly.  // Kent Williams and Tom Epperly.
 //  //
 // Redistribution and use in source and binary forms, with or without  //  Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions  //  modification, are permitted provided that the following conditions
 // are met:  //  are met:
 //  
 // 1. Redistributions of source code must retain the above copyright  
 //    notice, this list of conditions and the following disclaimer.  
 // 2. Redistributions in binary form must reproduce the above copyright  
 //    notice, this list of conditions and the following disclaimer in the  
 //    documentation and/or other materials provided with the distribution.  
 //  
 // Neither the name of the University nor the names of its contributors  
 // may be used to endorse or promote products derived from this software  
 // without specific prior written permission.  
 //  
 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR  
 // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED  
 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  
 // PURPOSE.  
   
   //  1. Redistributions of source code must retain the above copyright
   //  notice, this list of conditions and the following disclaimer.
   //  2. Redistributions in binary form must reproduce the above copyright
   //  notice, this list of conditions and the following disclaimer in the
   //  documentation and/or other materials provided with the distribution.
   
   //  Neither the name of the University nor the names of its contributors
   //  may be used to endorse or promote products derived from this software
   //  without specific prior written permission.
   
   //  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
   //  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   //  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   //  PURPOSE.
   
 // This file defines FlexLexer, an abstract class which specifies the  // This file defines FlexLexer, an abstract class which specifies the
 // external interface provided to flex C++ lexer objects, and yyFlexLexer,  // external interface provided to flex C++ lexer objects, and yyFlexLexer,
 // which defines a particular lexer class.  // which defines a particular lexer class.
Line 51 
Line 52 
 // Never included before - need to define base class.  // Never included before - need to define base class.
 #define __FLEX_LEXER_H  #define __FLEX_LEXER_H
   
   
 #include <iostream>  #include <iostream>
   #  ifndef FLEX_STD
   #    define FLEX_STD std::
   #  endif
   
 extern "C++" {  extern "C++" {
   
 struct yy_buffer_state;  struct yy_buffer_state;
 typedef int yy_state_type;  typedef int yy_state_type;
   
Line 61 
Line 66 
 public:  public:
         virtual ~FlexLexer()    { }          virtual ~FlexLexer()    { }
   
         const char* YYText()    { return yytext; }          const char* YYText() const      { return yytext; }
         int YYLeng()            { return yyleng; }          int YYLeng()    const   { return yyleng; }
   
         virtual void          virtual void
                 yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;                  yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
         virtual struct yy_buffer_state*          virtual struct yy_buffer_state*
                 yy_create_buffer( std::istream* s, int size ) = 0;                  yy_create_buffer( FLEX_STD istream* s, int size ) = 0;
         virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;          virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
         virtual void yyrestart( std::istream* s ) = 0;          virtual void yyrestart( FLEX_STD istream* s ) = 0;
   
         virtual int yylex() = 0;          virtual int yylex() = 0;
   
         // Call yylex with new input/output sources.          // Call yylex with new input/output sources.
         int yylex( std::istream* new_in, std::ostream* new_out = 0 )          int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 )
                 {                  {
                 switch_streams( new_in, new_out );                  switch_streams( new_in, new_out );
                 return yylex();                  return yylex();
Line 82 
Line 87 
   
         // Switch to new input/output streams.  A nil stream pointer          // Switch to new input/output streams.  A nil stream pointer
         // indicates "keep the current one".          // indicates "keep the current one".
         virtual void switch_streams( std::istream* new_in = 0,          virtual void switch_streams( FLEX_STD istream* new_in = 0,
                                         std::ostream* new_out = 0 ) = 0;                                          FLEX_STD ostream* new_out = 0 ) = 0;
   
         int lineno() const              { return yylineno; }          int lineno() const              { return yylineno; }
   
Line 98 
Line 103 
 };  };
   
 }  }
 #endif  #endif // FLEXLEXER_H
   
 #if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)  #if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
 // Either this is the first time through (yyFlexLexerOnce not defined),  // Either this is the first time through (yyFlexLexerOnce not defined),
 // or this is a repeated include to define a different flavor of  // or this is a repeated include to define a different flavor of
 // yyFlexLexer, as discussed in the flex man page.  // yyFlexLexer, as discussed in the flex manual.
 #define yyFlexLexerOnce  #define yyFlexLexerOnce
   
   extern "C++" {
   
 class yyFlexLexer : public FlexLexer {  class yyFlexLexer : public FlexLexer {
 public:  public:
         // arg_yyin and arg_yyout default to the cin and cout, but we          // arg_yyin and arg_yyout default to the cin and cout, but we
         // only make that assignment when initializing in yylex().          // only make that assignment when initializing in yylex().
         yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 );          yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 );
   
         virtual ~yyFlexLexer();          virtual ~yyFlexLexer();
   
         void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );          void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
         struct yy_buffer_state* yy_create_buffer( std::istream* s, int size );          struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size );
         void yy_delete_buffer( struct yy_buffer_state* b );          void yy_delete_buffer( struct yy_buffer_state* b );
         void yyrestart( std::istream* s );          void yyrestart( FLEX_STD istream* s );
   
           void yypush_buffer_state( struct yy_buffer_state* new_buffer );
           void yypop_buffer_state();
   
         virtual int yylex();          virtual int yylex();
         virtual void switch_streams( std::istream* new_in, std::ostream* new_out );          virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 );
           virtual int yywrap();
   
 protected:  protected:
         virtual int LexerInput( char* buf, int max_size );          virtual int LexerInput( char* buf, int max_size );
Line 131 
Line 142 
         int yyinput();          int yyinput();
   
         void yy_load_buffer_state();          void yy_load_buffer_state();
         void yy_init_buffer( struct yy_buffer_state* b, std::istream* s );          void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s );
         void yy_flush_buffer( struct yy_buffer_state* b );          void yy_flush_buffer( struct yy_buffer_state* b );
   
         int yy_start_stack_ptr;          int yy_start_stack_ptr;
Line 146 
Line 157 
         yy_state_type yy_try_NUL_trans( yy_state_type current_state );          yy_state_type yy_try_NUL_trans( yy_state_type current_state );
         int yy_get_next_buffer();          int yy_get_next_buffer();
   
         std::istream* yyin;     // input source for default LexerInput          FLEX_STD istream* yyin; // input source for default LexerInput
         std::ostream* yyout;    // output sink for default LexerOutput          FLEX_STD ostream* yyout;        // output sink for default LexerOutput
   
         struct yy_buffer_state* yy_current_buffer;  
   
         // yy_hold_char holds the character lost when yytext is formed.          // yy_hold_char holds the character lost when yytext is formed.
         char yy_hold_char;          char yy_hold_char;
   
Line 167 
Line 176 
         // instead of setting up a fresh yyin.  A bit of a hack ...          // instead of setting up a fresh yyin.  A bit of a hack ...
         int yy_did_buffer_switch_on_eof;          int yy_did_buffer_switch_on_eof;
   
   
           size_t yy_buffer_stack_top; /**< index of top of stack. */
           size_t yy_buffer_stack_max; /**< capacity of stack. */
           struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
           void yyensure_buffer_stack(void);
   
         // The following are not always needed, but may be depending          // The following are not always needed, but may be depending
         // on use of certain flex features (like REJECT or yymore()).          // on use of certain flex features (like REJECT or yymore()).
   
Line 189 
Line 204 
         int yy_prev_more_offset;          int yy_prev_more_offset;
 };  };
   
 #endif  }
   
   #endif // yyFlexLexer || ! yyFlexLexerOnce
   

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7