1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4
* Copyright (C) Eran Ifrah (Main file for CodeLite www.codelite.org/ )
5
* Copyright (C) Massimo Cora' 2009 <maxcvs@email.it> (Customizations for Anjuta)
7
* anjuta is free software: you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License as published by the
9
* Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
12
* anjuta is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
* See the GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License along
18
* with this program. If not, see <http://www.gnu.org/licenses/>.
21
//////////////////////////////////////////////////////////////////////////////
22
//////////////////////////////////////////////////////////////////////////////
24
// copyright : (C) 2008 by Eran Ifrah
25
// file name : FlexLexer.h
27
// -------------------------------------------------------------------------
30
// / __ \ | | | | (_) |
31
// | / \/ ___ __| | ___| | _| |_ ___
32
// | | / _ \ / _ |/ _ \ | | | __/ _ )
33
// | \__/\ (_) | (_| | __/ |___| | || __/
34
// \____/\___/ \__,_|\___\_____/_|\__\___|
38
// This program is free software; you can redistribute it and/or modify
39
// it under the terms of the GNU General Public License as published by
40
// the Free Software Foundation; either version 2 of the License, or
41
// (at your option) any later version.
43
//////////////////////////////////////////////////////////////////////////////
44
//////////////////////////////////////////////////////////////////////////////
45
// $Header: /CVS/wxUS/wxXtudio/Apps/USClient/FlexLexer.h,v 1.2 2006/02/08 14:30:12 eran Exp $
47
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
50
// Copyright (c) 1993 The Regents of the University of California.
51
// All rights reserved.
53
// This code is derived from software contributed to Berkeley by
54
// Kent Williams and Tom Epperly.
56
// Redistribution and use in source and binary forms with or without
57
// modification are permitted provided that: (1) source distributions retain
58
// this entire copyright notice and comment, and (2) distributions including
59
// binaries display the following acknowledgement: ``This product includes
60
// software developed by the University of California, Berkeley and its
61
// contributors'' in the documentation or other materials provided with the
62
// distribution and in all advertising materials mentioning features or use
63
// of this software. Neither the name of the University nor the names of
64
// its contributors may be used to endorse or promote products derived from
65
// this software without specific prior written permission.
67
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
68
// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
69
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
71
// This file defines FlexLexer, an abstract class which specifies the
72
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
73
// which defines a particular lexer class.
75
// If you want to create multiple lexer classes, you use the -P flag
76
// to rename each yyFlexLexer to some other xxFlexLexer. You then
77
// include <FlexLexer.h> in your other sources once per lexer class:
80
// #define yyFlexLexer xxFlexLexer
81
// #include <FlexLexer.h>
84
// #define yyFlexLexer zzFlexLexer
85
// #include <FlexLexer.h>
88
#ifndef CODELITE_FLEX_LEXER_H
89
// Never included before - need to define base class.
90
#define CODELITE_FLEX_LEXER_H
102
struct yy_buffer_state;
103
typedef int yy_state_type;
107
virtual ~FlexLexer() { }
109
const char* YYText() { return yytext; }
110
int YYLeng() { return yyleng; }
113
yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
114
virtual struct yy_buffer_state*
115
yy_create_buffer( std::istream* s, int size ) = 0;
116
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
117
virtual void yyrestart( std::istream* s ) = 0;
119
virtual int yylex() = 0;
121
/// Call yylex with new input/output sources.
122
int yylex( std::istream* new_in, std::ostream* new_out = 0 )
124
switch_streams( new_in, new_out );
128
/// Switch to new input/output streams. A nil stream pointer
129
/// indicates "keep the current one".
130
virtual void switch_streams( std::istream* new_in = 0,
131
std::ostream* new_out = 0 ) = 0;
133
int lineno() const { return yylineno; }
135
int debug() const { return yy_flex_debug; }
136
void set_debug( int flag ) { yy_flex_debug = flag; }
141
int yylineno; ///< only maintained if you use %option yylineno
142
int yy_flex_debug; ///< only has effect with -d or "%option debug"
144
/// Hack for keeping comments from the lexer
154
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
155
// Either this is the first time through (yyFlexLexerOnce not defined),
156
// or this is a repeated include to define a different flavor of
157
// yyFlexLexer, as discussed in the flex man page.
158
#define yyFlexLexerOnce
160
class yyFlexLexer : public FlexLexer {
162
/// arg_yyin and arg_yyout default to the cin and cout, but we
163
/// only make that assignment when initializing in yylex().
164
yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 );
166
virtual ~yyFlexLexer();
168
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
169
struct yy_buffer_state* yy_create_buffer( std::istream* s, int size );
170
void yy_delete_buffer( struct yy_buffer_state* b );
171
void yyrestart( std::istream* s );
174
virtual void switch_streams( std::istream* new_in, std::ostream* new_out );
177
virtual int LexerInput( char* buf, int max_size );
178
virtual void LexerOutput( const char* buf, int size );
179
virtual void LexerError( const char* msg );
181
void yyunput( int c, char* buf_ptr );
184
void yy_load_buffer_state();
185
void yy_init_buffer( struct yy_buffer_state* b, std::istream* s );
186
void yy_flush_buffer( struct yy_buffer_state* b );
188
int yy_start_stack_ptr;
189
int yy_start_stack_depth;
192
void yy_push_state( int new_state );
196
yy_state_type yy_get_previous_state();
197
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
198
int yy_get_next_buffer();
200
std::istream* yyin; ///< input source for default LexerInput
201
std::ostream* yyout; ///< output sink for default LexerOutput
203
struct yy_buffer_state* yy_current_buffer;
205
/// yy_hold_char holds the character lost when yytext is formed.
208
/// Number of characters read into yy_ch_buf.
211
/// Points to current character in buffer.
214
int yy_init; ///< whether we need to initialize
215
int yy_start; ///< start state number
217
/// Flag which is used to allow yywrap()'s to do buffer switches
218
/// instead of setting up a fresh yyin. A bit of a hack ...
219
int yy_did_buffer_switch_on_eof;
221
// The following are not always needed, but may be depending
222
// on use of certain flex features (like REJECT or yymore()).
224
yy_state_type yy_last_accepting_state;
225
char* yy_last_accepting_cpos;
227
yy_state_type* yy_state_buf;
228
yy_state_type* yy_state_ptr;
235
int yy_looking_for_trail_begin;
240
int yy_prev_more_offset;
245
#endif // CODELITE_FLEX_LEXER_H