FlexLexer.h (2258) | FlexLexer.h (16514) |
---|---|
1// $Header: FlexLexer.h,v 1.2 94/01/04 14:57:26 vern Exp $ | 1// $Header: /home/daffy/u0/vern/flex/RCS/FlexLexer.h,v 1.19 96/05/25 20:43:02 vern Exp $ |
2 | 2 |
3// FlexLexer.h -- define classes for lexical analyzers generated by flex | 3// FlexLexer.h -- define interfaces for lexical analyzer classes generated 4// by flex |
4 5// Copyright (c) 1993 The Regents of the University of California. 6// All rights reserved. 7// 8// This code is derived from software contributed to Berkeley by 9// Kent Williams and Tom Epperly. 10// 11// Redistribution and use in source and binary forms are permitted provided --- 5 unchanged lines hidden (view full) --- 17// all advertising materials mentioning features or use of this software. 18// Neither the name of the University nor the names of its contributors may 19// be used to endorse or promote products derived from this software without 20// specific prior written permission. 21// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 22// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 23// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 24 | 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 --- 5 unchanged lines hidden (view full) --- 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 |
25#ifndef __FLEX_LEXER_H 26#define __FLEX_LEXER_H 27 28 29// This file defines two classes. The first, FlexLexer, is an abstract 30// class which specifies the external interface provided to flex C++ 31// lexer objects. The second, yyFlexLexer, fills out most of the meat 32// of the lexer class; its internals may vary from lexer to lexer 33// depending on things like whether REJECT is used. | 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. |
34// 35// If you want to create multiple lexer classes, you use the -P flag | 29// 30// If you want to create multiple lexer classes, you use the -P flag |
36// to rename each yyFlexLexer to some other xxFlexLexer. | 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// ... |
37 | 42 |
43#ifndef __FLEX_LEXER_H 44// Never included before - need to define base class. 45#define __FLEX_LEXER_H |
|
38#include <iostream.h> 39 40extern "C++" { 41 42struct yy_buffer_state; 43typedef int yy_state_type; 44 45class FlexLexer { --- 7 unchanged lines hidden (view full) --- 53 yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0; 54 virtual struct yy_buffer_state* 55 yy_create_buffer( istream* s, int size ) = 0; 56 virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; 57 virtual void yyrestart( istream* s ) = 0; 58 59 virtual int yylex() = 0; 60 | 46#include <iostream.h> 47 48extern "C++" { 49 50struct yy_buffer_state; 51typedef int yy_state_type; 52 53class FlexLexer { --- 7 unchanged lines hidden (view full) --- 61 yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0; 62 virtual struct yy_buffer_state* 63 yy_create_buffer( istream* s, int size ) = 0; 64 virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; 65 virtual void yyrestart( istream* s ) = 0; 66 67 virtual int yylex() = 0; 68 |
69 // Call yylex with new input/output sources. 70 int yylex( istream* new_in, 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( istream* new_in = 0, 79 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 |
|
61protected: 62 char* yytext; 63 int yyleng; | 86protected: 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" |
|
64}; 65 | 91}; 92 |
93} 94#endif |
|
66 | 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 |
|
67class yyFlexLexer : public FlexLexer { 68public: 69 // arg_yyin and arg_yyout default to the cin and cout, but we 70 // only make that assignment when initializing in yylex(). | 102class yyFlexLexer : public FlexLexer { 103public: 104 // arg_yyin and arg_yyout default to the cin and cout, but we 105 // only make that assignment when initializing in yylex(). |
71 yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 ) 72 { 73 yyin = arg_yyin; 74 yyout = arg_yyout; 75 yy_c_buf_p = 0; 76 yy_init = 1; 77 yy_start = 0; | 106 yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 ); |
78 | 107 |
79 yy_did_buffer_switch_on_eof = 0; | 108 virtual ~yyFlexLexer(); |
80 | 109 |
81 yy_looking_for_trail_begin = 0; 82 yy_more_flag = 0; 83 yy_more_len = 0; 84 85 yy_start_stack_ptr = yy_start_stack_depth = 0; 86 yy_start_stack = 0; 87 88 yy_current_buffer = 0; 89 90#ifdef YY_USES_REJECT 91 yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2]; 92#else 93 yy_state_buf = 0; 94#endif 95 } 96 97 virtual ~yyFlexLexer() 98 { 99 delete yy_state_buf; 100 } 101 | |
102 void yy_switch_to_buffer( struct yy_buffer_state* new_buffer ); 103 struct yy_buffer_state* yy_create_buffer( istream* s, int size ); 104 void yy_delete_buffer( struct yy_buffer_state* b ); 105 void yyrestart( istream* s ); 106 107 virtual int yylex(); | 110 void yy_switch_to_buffer( struct yy_buffer_state* new_buffer ); 111 struct yy_buffer_state* yy_create_buffer( istream* s, int size ); 112 void yy_delete_buffer( struct yy_buffer_state* b ); 113 void yyrestart( istream* s ); 114 115 virtual int yylex(); |
116 virtual void switch_streams( istream* new_in, ostream* new_out ); |
|
108 109protected: 110 virtual int LexerInput( char* buf, int max_size ); 111 virtual void LexerOutput( const char* buf, int size ); 112 virtual void LexerError( const char* msg ); 113 114 void yyunput( int c, char* buf_ptr ); 115 int yyinput(); 116 117 void yy_load_buffer_state(); 118 void yy_init_buffer( struct yy_buffer_state* b, istream* s ); | 117 118protected: 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, istream* s ); |
128 void yy_flush_buffer( struct yy_buffer_state* b ); |
|
119 120 int yy_start_stack_ptr; 121 int yy_start_stack_depth; 122 int* yy_start_stack; 123 124 void yy_push_state( int new_state ); 125 void yy_pop_state(); 126 int yy_top_state(); --- 36 unchanged lines hidden (view full) --- 163 int* yy_full_state; 164 int yy_full_lp; 165 166 int yy_lp; 167 int yy_looking_for_trail_begin; 168 169 int yy_more_flag; 170 int yy_more_len; | 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(); --- 36 unchanged lines hidden (view full) --- 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; |
|
171}; 172 | 183}; 184 |
173} 174 | |
175#endif | 185#endif |