Debian Codegraph @

CodeLite/FlexLexer.h

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