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