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