| 1 |
// $Header: /hosts/bonnie.engr.sgi.com/proj/irix6.5/isms/eoe/cmd/flex/flex-2.5.4/RCS/FlexLexer.h,v 1.1 1997/01/24 05:34:27 leedom Exp $ |
|---|
| 2 |
|
|---|
| 3 |
// FlexLexer.h -- define interfaces for lexical analyzer classes generated |
|---|
| 4 |
// by flex |
|---|
| 5 |
|
|---|
| 6 |
// Copyright (c) 1993 The Regents of the University of California. |
|---|
| 7 |
// All rights reserved. |
|---|
| 8 |
// |
|---|
| 9 |
// This code is derived from software contributed to Berkeley by |
|---|
| 10 |
// Kent Williams and Tom Epperly. |
|---|
| 11 |
// |
|---|
| 12 |
// Redistribution and use in source and binary forms are permitted provided |
|---|
| 13 |
// that: (1) source distributions retain this entire copyright notice and |
|---|
| 14 |
// comment, and (2) distributions including binaries display the following |
|---|
| 15 |
// acknowledgement: ``This product includes software developed by the |
|---|
| 16 |
// University of California, Berkeley and its contributors'' in the |
|---|
| 17 |
// documentation or other materials provided with the distribution and in |
|---|
| 18 |
// all advertising materials mentioning features or use of this software. |
|---|
| 19 |
// Neither the name of the University nor the names of its contributors may |
|---|
| 20 |
// be used to endorse or promote products derived from this software without |
|---|
| 21 |
// specific prior written permission. |
|---|
| 22 |
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
|---|
| 23 |
// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
|---|
| 24 |
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 25 |
|
|---|
| 26 |
// This file defines FlexLexer, an abstract class which specifies the |
|---|
| 27 |
// external interface provided to flex C++ lexer objects, and yyFlexLexer, |
|---|
| 28 |
// which defines a particular lexer class. |
|---|
| 29 |
// |
|---|
| 30 |
// If you want to create multiple lexer classes, you use the -P flag |
|---|
| 31 |
// to rename each yyFlexLexer to some other xxFlexLexer. You then |
|---|
| 32 |
// include <FlexLexer.h> in your other sources once per lexer class: |
|---|
| 33 |
// |
|---|
| 34 |
// #undef yyFlexLexer |
|---|
| 35 |
// #define yyFlexLexer xxFlexLexer |
|---|
| 36 |
// #include <FlexLexer.h> |
|---|
| 37 |
// |
|---|
| 38 |
// #undef yyFlexLexer |
|---|
| 39 |
// #define yyFlexLexer zzFlexLexer |
|---|
| 40 |
// #include <FlexLexer.h> |
|---|
| 41 |
// ... |
|---|
| 42 |
|
|---|
| 43 |
#ifndef __FLEX_LEXER_H |
|---|
| 44 |
// Never included before - need to define base class. |
|---|
| 45 |
#define __FLEX_LEXER_H |
|---|
| 46 |
#include <iostream> |
|---|
| 47 |
|
|---|
| 48 |
//extern "C++" { |
|---|
| 49 |
|
|---|
| 50 |
struct yy_buffer_state; |
|---|
| 51 |
typedef int yy_state_type; |
|---|
| 52 |
|
|---|
| 53 |
class FlexLexer { |
|---|
| 54 |
public: |
|---|
| 55 |
virtual ~FlexLexer() { } |
|---|
| 56 |
|
|---|
| 57 |
const char* YYText() { return yytext; } |
|---|
| 58 |
int YYLeng() { return yyleng; } |
|---|
| 59 |
|
|---|
| 60 |
virtual void |
|---|
| 61 |
yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0; |
|---|
| 62 |
virtual struct yy_buffer_state* |
|---|
| 63 |
yy_create_buffer( std::istream* s, int size ) = 0; |
|---|
| 64 |
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; |
|---|
| 65 |
virtual void yyrestart( std::istream* s ) = 0; |
|---|
| 66 |
|
|---|
| 67 |
virtual int yylex() = 0; |
|---|
| 68 |
|
|---|
| 69 |
// Call yylex with new input/output sources. |
|---|
| 70 |
int yylex( std::istream* new_in, std::ostream* new_out = 0 ) |
|---|
| 71 |
{ |
|---|
| 72 |
switch_streams( new_in, new_out ); |
|---|
| 73 |
return yylex(); |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
// Switch to new input/output streams. A nil stream pointer |
|---|
| 77 |
// indicates "keep the current one". |
|---|
| 78 |
virtual void switch_streams( std::istream* new_in = 0, |
|---|
| 79 |
std::ostream* new_out = 0 ) = 0; |
|---|
| 80 |
|
|---|
| 81 |
int lineno() const { return yylineno; } |
|---|
| 82 |
|
|---|
| 83 |
int debug() const { return yy_flex_debug; } |
|---|
| 84 |
void set_debug( int flag ) { yy_flex_debug = flag; } |
|---|
| 85 |
|
|---|
| 86 |
protected: |
|---|
| 87 |
char* yytext; |
|---|
| 88 |
int yyleng; |
|---|
| 89 |
int yylineno; // only maintained if you use %option yylineno |
|---|
| 90 |
int yy_flex_debug; // only has effect with -d or "%option debug" |
|---|
| 91 |
}; |
|---|
| 92 |
|
|---|
| 93 |
//} |
|---|
| 94 |
#endif |
|---|
| 95 |
|
|---|
| 96 |
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) |
|---|
| 97 |
// Either this is the first time through (yyFlexLexerOnce not defined), |
|---|
| 98 |
// or this is a repeated include to define a different flavor of |
|---|
| 99 |
// yyFlexLexer, as discussed in the flex man page. |
|---|
| 100 |
#define yyFlexLexerOnce |
|---|
| 101 |
|
|---|
| 102 |
class yyFlexLexer : public FlexLexer { |
|---|
| 103 |
public: |
|---|
| 104 |
// arg_yyin and arg_yyout default to the cin and cout, but we |
|---|
| 105 |
// only make that assignment when initializing in yylex(). |
|---|
| 106 |
yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 ); |
|---|
| 107 |
|
|---|
| 108 |
virtual ~yyFlexLexer(); |
|---|
| 109 |
|
|---|
| 110 |
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer ); |
|---|
| 111 |
struct yy_buffer_state* yy_create_buffer( std::istream* s, int size ); |
|---|
| 112 |
void yy_delete_buffer( struct yy_buffer_state* b ); |
|---|
| 113 |
void yyrestart( std::istream* s ); |
|---|
| 114 |
|
|---|
| 115 |
virtual int yylex(); |
|---|
| 116 |
virtual void switch_streams( std::istream* new_in, std::ostream* new_out ); |
|---|
| 117 |
|
|---|
| 118 |
protected: |
|---|
| 119 |
virtual int LexerInput( char* buf, int max_size ); |
|---|
| 120 |
virtual void LexerOutput( const char* buf, int size ); |
|---|
| 121 |
virtual void LexerError( const char* msg ); |
|---|
| 122 |
|
|---|
| 123 |
void yyunput( int c, char* buf_ptr ); |
|---|
| 124 |
int yyinput(); |
|---|
| 125 |
|
|---|
| 126 |
void yy_load_buffer_state(); |
|---|
| 127 |
void yy_init_buffer( struct yy_buffer_state* b, std::istream* s ); |
|---|
| 128 |
void yy_flush_buffer( struct yy_buffer_state* b ); |
|---|
| 129 |
|
|---|
| 130 |
int yy_start_stack_ptr; |
|---|
| 131 |
int yy_start_stack_depth; |
|---|
| 132 |
int* yy_start_stack; |
|---|
| 133 |
|
|---|
| 134 |
void yy_push_state( int new_state ); |
|---|
| 135 |
void yy_pop_state(); |
|---|
| 136 |
int yy_top_state(); |
|---|
| 137 |
|
|---|
| 138 |
yy_state_type yy_get_previous_state(); |
|---|
| 139 |
yy_state_type yy_try_NUL_trans( yy_state_type current_state ); |
|---|
| 140 |
int yy_get_next_buffer(); |
|---|
| 141 |
|
|---|
| 142 |
std::istream* yyin; // input source for default LexerInput |
|---|
| 143 |
std::ostream* yyout; // output sink for default LexerOutput |
|---|
| 144 |
|
|---|
| 145 |
struct yy_buffer_state* yy_current_buffer; |
|---|
| 146 |
|
|---|
| 147 |
// yy_hold_char holds the character lost when yytext is formed. |
|---|
| 148 |
char yy_hold_char; |
|---|
| 149 |
|
|---|
| 150 |
// Number of characters read into yy_ch_buf. |
|---|
| 151 |
int yy_n_chars; |
|---|
| 152 |
|
|---|
| 153 |
// Points to current character in buffer. |
|---|
| 154 |
char* yy_c_buf_p; |
|---|
| 155 |
|
|---|
| 156 |
int yy_init; // whether we need to initialize |
|---|
| 157 |
int yy_start; // start state number |
|---|
| 158 |
|
|---|
| 159 |
// Flag which is used to allow yywrap()'s to do buffer switches |
|---|
| 160 |
// instead of setting up a fresh yyin. A bit of a hack ... |
|---|
| 161 |
int yy_did_buffer_switch_on_eof; |
|---|
| 162 |
|
|---|
| 163 |
// The following are not always needed, but may be depending |
|---|
| 164 |
// on use of certain flex features (like REJECT or yymore()). |
|---|
| 165 |
|
|---|
| 166 |
yy_state_type yy_last_accepting_state; |
|---|
| 167 |
char* yy_last_accepting_cpos; |
|---|
| 168 |
|
|---|
| 169 |
yy_state_type* yy_state_buf; |
|---|
| 170 |
yy_state_type* yy_state_ptr; |
|---|
| 171 |
|
|---|
| 172 |
char* yy_full_match; |
|---|
| 173 |
int* yy_full_state; |
|---|
| 174 |
int yy_full_lp; |
|---|
| 175 |
|
|---|
| 176 |
int yy_lp; |
|---|
| 177 |
int yy_looking_for_trail_begin; |
|---|
| 178 |
|
|---|
| 179 |
int yy_more_flag; |
|---|
| 180 |
int yy_more_len; |
|---|
| 181 |
int yy_more_offset; |
|---|
| 182 |
int yy_prev_more_offset; |
|---|
| 183 |
}; |
|---|
| 184 |
|
|---|
| 185 |
#endif |
|---|