Aprepro 5.0x

FlexLexer.h
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 #include "aprepro_parser.h"
52
53 extern "C++" {
54
55 struct yy_buffer_state;
56 typedef int yy_state_type;
57
58 class FlexLexer
59 {
60 public:
61 FlexLexer() : yytext(nullptr), yyleng(0), yylineno(0), yy_flex_debug(0) {}
62 virtual ~FlexLexer() {}
63
64 const char *YYText() const { return yytext; }
65 int YYLeng() const { return yyleng; }
66
67 virtual void yy_switch_to_buffer(struct yy_buffer_state *new_buffer) = 0;
68 virtual struct yy_buffer_state *yy_create_buffer(std::istream *s, int size) = 0;
69 virtual void yy_delete_buffer(struct yy_buffer_state *b) = 0;
70 virtual void yyrestart(std::istream *s) = 0;
71
72 virtual int yylex() = 0;
73
74 // Call yylex with new input/output sources.
75 int yylex(std::istream *new_in, std::ostream *new_out = nullptr)
76 {
77 switch_streams(new_in, new_out);
78 return yylex();
79 }
80
81 // Switch to new input/output streams. A nil stream pointer
82 // indicates "keep the current one".
83 virtual void switch_streams(std::istream *new_in = nullptr, std::ostream *new_out = nullptr) = 0;
84
85 int lineno() const { return yylineno; }
86
87 int debug() const { return yy_flex_debug; }
88 void set_debug(int flag) { yy_flex_debug = flag; }
89
90 protected:
91 char *yytext;
92 int yyleng;
93 int yylineno; // only maintained if you use %option yylineno
94 int yy_flex_debug; // only has effect with -d or "%option debug"
95 };
96 }
97 #endif // FLEXLEXER_H
98
99 #if defined(yyFlexLexer) || !defined(yyFlexLexerOnce)
100 // Either this is the first time through (yyFlexLexerOnce not defined),
101 // or this is a repeated include to define a different flavor of
102 // yyFlexLexer, as discussed in the flex manual.
103 #define yyFlexLexerOnce
104
105 extern "C++" {
106
107 class yyFlexLexer : public FlexLexer
108 {
109 public:
110 // arg_yyin and arg_yyout default to the cin and cout, but we
111 // only make that assignment when initializing in yylex().
112 explicit yyFlexLexer(std::istream *arg_yyin = nullptr, std::ostream *arg_yyout = nullptr);
113
114 ~yyFlexLexer() override;
115
116 void yy_switch_to_buffer(struct yy_buffer_state *new_buffer) override;
117 struct yy_buffer_state *yy_create_buffer(std::istream *file, int size) override;
118 void yy_delete_buffer(struct yy_buffer_state *b) override;
119 void yyrestart(std::istream *input_file) override;
120
121 void yypush_buffer_state(struct yy_buffer_state *new_buffer);
122 void yypop_buffer_state();
123
124 int yylex() override;
125 void switch_streams(std::istream *new_in, std::ostream *new_out = nullptr) override;
126 virtual int yywrap();
127
128 protected:
129 virtual int LexerInput(char *buf, int max_size);
130 virtual void LexerOutput(const char *buf, int size);
131 virtual void LexerError(const char *msg);
132
133 void yyunput(int c, char *yy_bp);
134 int yyinput();
135
136 void yy_load_buffer_state();
137 void yy_init_buffer(struct yy_buffer_state *b, std::istream *file);
138 void yy_flush_buffer(struct yy_buffer_state *b);
139
140 int yy_start_stack_ptr;
141 int yy_start_stack_depth;
142 int *yy_start_stack;
143
144 void yy_push_state(int new_state);
145 void yy_pop_state();
146 int yy_top_state();
147
148 yy_state_type yy_get_previous_state();
149 yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state);
150 int yy_get_next_buffer();
151
152 std::istream *yyin; // input source for default LexerInput
153 std::ostream *yyout; // output sink for default LexerOutput
154
155 // yy_hold_char holds the character lost when yytext is formed.
156 char yy_hold_char;
157
158 // Number of characters read into yy_ch_buf.
159 int yy_n_chars;
160
161 // Points to current character in buffer.
162 char *yy_c_buf_p;
163
164 int yy_init; // whether we need to initialize
165 int yy_start; // start state number
166
167 // Flag which is used to allow yywrap()'s to do buffer switches
168 // instead of setting up a fresh yyin. A bit of a hack ...
169 int yy_did_buffer_switch_on_eof;
170
171 size_t yy_buffer_stack_top; /**< index of top of stack. */
172 size_t yy_buffer_stack_max; /**< capacity of stack. */
173 struct yy_buffer_state **yy_buffer_stack; /**< Stack as an array. */
174 void yyensure_buffer_stack(void);
175
176 // The following are not always needed, but may be depending
177 // on use of certain flex features (like REJECT or yymore()).
178
179 yy_state_type yy_last_accepting_state;
180 char * yy_last_accepting_cpos;
181
182 yy_state_type *yy_state_buf;
183 yy_state_type *yy_state_ptr;
184
185 char *yy_full_match;
186 int * yy_full_state;
187 int yy_full_lp;
188
189 int yy_lp;
190 int yy_looking_for_trail_begin;
191
192 int yy_more_flag;
193 int yy_more_len;
194 int yy_more_offset;
195 int yy_prev_more_offset;
196 };
197 }
198
199 #endif // yyFlexLexer || ! yyFlexLexerOnce
yyFlexLexer::yylex
int yylex() override
FlexLexer::yy_flex_debug
int yy_flex_debug
Definition: FlexLexer.h:94
yyFlexLexer::yypush_buffer_state
void yypush_buffer_state(struct yy_buffer_state *new_buffer)
Definition: apr_scanner.cc:2906
yyFlexLexer::yy_init_buffer
void yy_init_buffer(struct yy_buffer_state *b, std::istream *file)
Definition: apr_scanner.cc:2837
yyFlexLexer::yy_start_stack_ptr
int yy_start_stack_ptr
Definition: FlexLexer.h:140
yyFlexLexer::yy_state_ptr
yy_state_type * yy_state_ptr
Definition: FlexLexer.h:183
yyFlexLexer::yy_push_state
void yy_push_state(int new_state)
Definition: apr_scanner.cc:3021
yyFlexLexer::yy_buffer_stack_top
size_t yy_buffer_stack_top
Definition: FlexLexer.h:171
yyFlexLexer::yy_prev_more_offset
int yy_prev_more_offset
Definition: FlexLexer.h:195
FlexLexer::yy_switch_to_buffer
virtual void yy_switch_to_buffer(struct yy_buffer_state *new_buffer)=0
yyFlexLexer::yy_start_stack
int * yy_start_stack
Definition: FlexLexer.h:142
FlexLexer::yyrestart
virtual void yyrestart(std::istream *s)=0
yyFlexLexer::switch_streams
void switch_streams(std::istream *new_in, std::ostream *new_out=nullptr) override
Definition: apr_scanner.cc:2353
FlexLexer::yyleng
int yyleng
Definition: FlexLexer.h:92
yyFlexLexer::yy_state_buf
yy_state_type * yy_state_buf
Definition: FlexLexer.h:182
yyFlexLexer::yy_flush_buffer
void yy_flush_buffer(struct yy_buffer_state *b)
Definition: apr_scanner.cc:2872
yyFlexLexer::yy_full_lp
int yy_full_lp
Definition: FlexLexer.h:187
yyFlexLexer::yy_hold_char
char yy_hold_char
Definition: FlexLexer.h:156
yyFlexLexer::yy_last_accepting_state
yy_state_type yy_last_accepting_state
Definition: FlexLexer.h:179
yyFlexLexer::yy_init
int yy_init
Definition: FlexLexer.h:164
yyFlexLexer::yy_more_offset
int yy_more_offset
Definition: FlexLexer.h:194
yyFlexLexer::yy_switch_to_buffer
void yy_switch_to_buffer(struct yy_buffer_state *new_buffer) override
Definition: apr_scanner.cc:2730
yyFlexLexer::yy_more_flag
int yy_more_flag
Definition: FlexLexer.h:192
yyFlexLexer::yyin
std::istream * yyin
Definition: FlexLexer.h:152
yyFlexLexer::yyinput
int yyinput()
Definition: apr_scanner.cc:2636
yyFlexLexer::yypop_buffer_state
void yypop_buffer_state()
Definition: apr_scanner.cc:2941
FlexLexer::yylex
virtual int yylex()=0
yyFlexLexer::yy_last_accepting_cpos
char * yy_last_accepting_cpos
Definition: FlexLexer.h:180
aprepro_parser.h
FlexLexer::~FlexLexer
virtual ~FlexLexer()
Definition: FlexLexer.h:62
yyFlexLexer::yy_load_buffer_state
void yy_load_buffer_state()
Definition: apr_scanner.cc:2764
yy_state_type
int yy_state_type
Definition: FlexLexer.h:55
FlexLexer::yylineno
int yylineno
Definition: FlexLexer.h:93
yyFlexLexer::LexerError
virtual void LexerError(const char *msg)
Definition: apr_scanner.cc:3070
yyFlexLexer::yy_looking_for_trail_begin
int yy_looking_for_trail_begin
Definition: FlexLexer.h:190
yyFlexLexer::LexerInput
virtual int LexerInput(char *buf, int max_size)
Definition: apr_scanner.cc:2365
FlexLexer::yytext
char * yytext
Definition: FlexLexer.h:91
yyFlexLexer::yy_buffer_stack_max
size_t yy_buffer_stack_max
Definition: FlexLexer.h:172
yyFlexLexer::yy_did_buffer_switch_on_eof
int yy_did_buffer_switch_on_eof
Definition: FlexLexer.h:169
yyFlexLexer
Definition: FlexLexer.h:107
FlexLexer::FlexLexer
FlexLexer()
Definition: FlexLexer.h:61
yyFlexLexer::yy_full_match
char * yy_full_match
Definition: FlexLexer.h:185
yyFlexLexer::yy_buffer_stack
struct yy_buffer_state ** yy_buffer_stack
Definition: FlexLexer.h:173
FlexLexer::lineno
int lineno() const
Definition: FlexLexer.h:85
yyFlexLexer::yy_c_buf_p
char * yy_c_buf_p
Definition: FlexLexer.h:162
yyFlexLexer::LexerOutput
virtual void LexerOutput(const char *buf, int size)
Definition: apr_scanner.cc:2394
yy_buffer_state
Definition: apr_scanner.cc:238
yyFlexLexer::yy_delete_buffer
void yy_delete_buffer(struct yy_buffer_state *b) override
Definition: apr_scanner.cc:2814
yyFlexLexer::yy_get_next_buffer
int yy_get_next_buffer()
Definition: apr_scanner.cc:2409
yyFlexLexer::yy_create_buffer
struct yy_buffer_state * yy_create_buffer(std::istream *file, int size) override
Definition: apr_scanner.cc:2782
yyFlexLexer::yyensure_buffer_stack
void yyensure_buffer_stack(void)
Definition: apr_scanner.cc:2966
yyFlexLexer::yy_full_state
int * yy_full_state
Definition: FlexLexer.h:186
FlexLexer::yylex
int yylex(std::istream *new_in, std::ostream *new_out=nullptr)
Definition: FlexLexer.h:75
yyFlexLexer::yy_start
int yy_start
Definition: FlexLexer.h:165
yyFlexLexer::yy_n_chars
int yy_n_chars
Definition: FlexLexer.h:159
FlexLexer::yy_create_buffer
virtual struct yy_buffer_state * yy_create_buffer(std::istream *s, int size)=0
FlexLexer::set_debug
void set_debug(int flag)
Definition: FlexLexer.h:88
yyFlexLexer::~yyFlexLexer
~yyFlexLexer() override
Definition: apr_scanner.cc:2343
yyFlexLexer::yyFlexLexer
yyFlexLexer(std::istream *arg_yyin=nullptr, std::ostream *arg_yyout=nullptr)
Definition: apr_scanner.cc:2314
yyFlexLexer::yy_top_state
int yy_top_state()
Definition: apr_scanner.cc:3060
FlexLexer::yy_delete_buffer
virtual void yy_delete_buffer(struct yy_buffer_state *b)=0
yyFlexLexer::yy_start_stack_depth
int yy_start_stack_depth
Definition: FlexLexer.h:141
yyFlexLexer::yy_pop_state
void yy_pop_state()
Definition: apr_scanner.cc:3048
FlexLexer::YYText
const char * YYText() const
Definition: FlexLexer.h:64
FlexLexer::YYLeng
int YYLeng() const
Definition: FlexLexer.h:65
yyFlexLexer::yyunput
void yyunput(int c, char *yy_bp)
Definition: apr_scanner.cc:2595
yyFlexLexer::yy_get_previous_state
yy_state_type yy_get_previous_state()
Definition: apr_scanner.cc:2534
yyFlexLexer::yywrap
virtual int yywrap()
yyFlexLexer::yy_lp
int yy_lp
Definition: FlexLexer.h:189
FlexLexer::debug
int debug() const
Definition: FlexLexer.h:87
FlexLexer
Definition: FlexLexer.h:58
FlexLexer::switch_streams
virtual void switch_streams(std::istream *new_in=nullptr, std::ostream *new_out=nullptr)=0
yyFlexLexer::yy_more_len
int yy_more_len
Definition: FlexLexer.h:193
yyFlexLexer::yyout
std::ostream * yyout
Definition: FlexLexer.h:153
yy_bp
char * yy_bp
Definition: apr_scanner.cc:1235
yyFlexLexer::yyrestart
void yyrestart(std::istream *input_file) override
Definition: apr_scanner.cc:2710
yyFlexLexer::yy_try_NUL_trans
yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state)
Definition: apr_scanner.cc:2569