Vcsn  2.4
Be Rational
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 VCSN_MISC_FLEX_LEXER_HH
48 # define VCSN_MISC_FLEX_LEXER_HH
49 
50 # include <iosfwd>
51 # include <ostream>
52 
53 # include <vcsn/config.hh>
54 
55 # ifndef FLEX_STD
56 # define FLEX_STD std::
57 # endif
58 
59 struct yy_buffer_state;
60 typedef int yy_state_type;
61 
62 class FlexLexer
63 {
64 public:
65  virtual ~FlexLexer() { }
66 
67  const char* YYText() const { return yytext; }
68  int YYLeng() const { return yyleng; }
69 
70  virtual void yy_switch_to_buffer( yy_buffer_state* new_buffer ) = 0;
71  virtual yy_buffer_state* yy_create_buffer( std::istream* s, int size ) = 0;
72  virtual void yy_delete_buffer( yy_buffer_state* b ) = 0;
73  virtual void yyrestart( std::istream* s ) = 0;
74 
75 #if 2 <= VCSN_FLEX_MAJOR_VERSION && 6 <= VCSN_FLEX_MINOR_VERSION
76  virtual yy_buffer_state* yy_create_buffer( std::istream& s, int size ) = 0;
77  virtual void switch_streams(std::istream& new_in, std::ostream& new_out ) = 0;
78  virtual void yyrestart( std::istream& s ) = 0;
79 #endif
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,
84  std::ostream* new_out = nullptr ) = 0;
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 
98 
99 void *yyalloc (size_t);
100 void *yyrealloc (void *, size_t);
101 void yyfree (void *);
102 
103 class yyFlexLexer : public FlexLexer
104 {
105 public:
106  // arg_yyin and arg_yyout default to the cin and cout, but we
107  // only make that assignment when initializing in yylex().
108  yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout );
109  yyFlexLexer( std::istream* arg_yyin = nullptr, std::ostream* arg_yyout = nullptr );
110 
111 private:
112  void ctor_common();
113 
114 public:
115 
116  virtual ~yyFlexLexer();
117 
118  void yy_switch_to_buffer( yy_buffer_state* new_buffer );
119  yy_buffer_state* yy_create_buffer( std::istream* s, int size );
120  void yy_delete_buffer( yy_buffer_state* b );
121  void yyrestart( std::istream* s );
122 
123  void yypush_buffer_state( yy_buffer_state* new_buffer );
124  void yypop_buffer_state();
125 
126  // The signature of yylex.
127  YY_DECL_();
128 
129  void scan_open_(std::istream& f);
130 
131  void scan_close_();
132 
134 
135  virtual void switch_streams(std::istream* new_in,
136  std::ostream* new_out = nullptr );
137  virtual int yywrap();
138 
139 #if 2 <= VCSN_FLEX_MAJOR_VERSION && 6 <= VCSN_FLEX_MINOR_VERSION
140  virtual yy_buffer_state* yy_create_buffer( std::istream& s, int size );
141  void yy_init_buffer( yy_buffer_state* b, std::istream& s );
142  virtual void switch_streams(std::istream& new_in, std::ostream& new_out );
143  virtual void yyrestart( std::istream& s );
144 
145  std::istream yyin; // input source for default LexerInput
146  void putback(char c) { yyin.putback(c); }
147 #else
148  std::istream * yyin; // input source for default LexerInput
149  void putback(char c) { yyin->putback(c); }
150 #endif
151 
152 protected:
153  virtual int LexerInput( char* buf, int max_size );
154  virtual void LexerOutput( const char* buf, int size );
155  virtual void LexerError( const char* msg );
156 
157  void yyunput( int c, char* buf_ptr );
158  int yyinput();
159 
160  void yy_load_buffer_state();
161  void yy_init_buffer( yy_buffer_state* b, std::istream* s );
162  void yy_flush_buffer( yy_buffer_state* b );
163 
167 
168  void yy_push_state( int new_state );
169  void yy_pop_state();
170  int yy_top_state();
171 
174  int yy_get_next_buffer();
175 
176 #if 2 <= VCSN_FLEX_MAJOR_VERSION && 6 <= VCSN_FLEX_MINOR_VERSION
177  std::ostream yyout; // output sink for default LexerOutput
178 #else
179  std::ostream * yyout; // output sink for default LexerOutput
180 #endif
181 
182  // yy_hold_char holds the character lost when yytext is formed.
184 
185  // Number of characters read into yy_ch_buf.
187 
188  // Points to current character in buffer.
189  char* yy_c_buf_p;
190 
191  int yy_init; // whether we need to initialize
192  int yy_start; // start state number
193 
194  // Flag which is used to allow yywrap()'s to do buffer switches
195  // instead of setting up a fresh yyin. A bit of a hack ...
197 
198 
201  yy_buffer_state ** yy_buffer_stack;
202  void yyensure_buffer_stack(void);
203 
204  // The following are not always needed, but may be depending
205  // on use of certain flex features (like REJECT or yymore()).
206 
209 
212 
216 
217  int yy_lp;
219 
224 };
225 
227 
228 #endif // !VCSN_MISC_FLEX_LEXER_HH
size_t yy_buffer_stack_top
index of top of stack.
Definition: flex-lexer.hh:199
virtual void LexerOutput(const char *buf, int size)
YY_FLEX_NAMESPACE_BEGIN void * yyalloc(size_t)
virtual yy_buffer_state * yy_create_buffer(std::istream *s, int size)=0
#define YY_FLEX_NAMESPACE_END
Definition: scan.hh:9
int debug() const
Definition: flex-lexer.hh:87
void * yyrealloc(void *, size_t)
void scan_close_()
int yy_prev_more_offset
Definition: flex-lexer.hh:223
virtual ~FlexLexer()
Definition: flex-lexer.hh:65
yy_buffer_state ** yy_buffer_stack
Stack as an array.
Definition: flex-lexer.hh:201
virtual void switch_streams(std::istream *new_in, std::ostream *new_out=nullptr)
char * yy_last_accepting_cpos
Definition: flex-lexer.hh:208
int yy_looking_for_trail_begin
Definition: flex-lexer.hh:218
char yy_hold_char
Definition: flex-lexer.hh:183
yy_state_type yy_try_NUL_trans(yy_state_type current_state)
void yy_delete_buffer(yy_buffer_state *b)
int yy_state_type
Definition: flex-lexer.hh:59
location loc
Definition: flex-lexer.hh:133
int lineno() const
Definition: flex-lexer.hh:85
yy_state_type * yy_state_buf
Definition: flex-lexer.hh:210
int yyleng
Definition: flex-lexer.hh:92
virtual ~yyFlexLexer()
void yy_pop_state()
int yylineno
Definition: flex-lexer.hh:93
std::istream * yyin
Definition: flex-lexer.hh:148
void yypush_buffer_state(yy_buffer_state *new_buffer)
yyFlexLexer(std::istream &arg_yyin, std::ostream &arg_yyout)
int yy_start_stack_depth
Definition: flex-lexer.hh:165
int YYLeng() const
Definition: flex-lexer.hh:68
char * yy_c_buf_p
Definition: flex-lexer.hh:189
int yy_did_buffer_switch_on_eof
Definition: flex-lexer.hh:196
char * yytext
Definition: flex-lexer.hh:91
yy_state_type yy_last_accepting_state
Definition: flex-lexer.hh:207
void yy_load_buffer_state()
int yy_more_offset
Definition: flex-lexer.hh:222
weightset_mixin< detail::b_impl > b
Definition: fwd.hh:48
void yy_push_state(int new_state)
const char * YYText() const
Definition: flex-lexer.hh:67
void yyensure_buffer_stack(void)
void yy_init_buffer(yy_buffer_state *b, std::istream *s)
virtual int LexerInput(char *buf, int max_size)
void yyfree(void *)
void yypop_buffer_state()
yy_state_type * yy_state_ptr
Definition: flex-lexer.hh:211
yy_buffer_state * yy_create_buffer(std::istream *s, int size)
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
char * yy_full_match
Definition: flex-lexer.hh:213
virtual void yy_switch_to_buffer(yy_buffer_state *new_buffer)=0
virtual int yywrap()
int yy_top_state()
yy_state_type yy_get_previous_state()
int yy_flex_debug
Definition: flex-lexer.hh:94
int yy_start_stack_ptr
Definition: flex-lexer.hh:164
virtual void yy_delete_buffer(yy_buffer_state *b)=0
int * yy_full_state
Definition: flex-lexer.hh:214
int * yy_start_stack
Definition: flex-lexer.hh:166
void yyrestart(std::istream *s)
size_t yy_buffer_stack_max
capacity of stack.
Definition: flex-lexer.hh:200
virtual void LexerError(const char *msg)
void ctor_common()
int yy_get_next_buffer()
void scan_open_(std::istream &f)
#define YY_FLEX_NAMESPACE_BEGIN
Definition: scan.hh:4
std::ostream * yyout
Definition: flex-lexer.hh:179
virtual void yyrestart(std::istream *s)=0
void yy_flush_buffer(yy_buffer_state *b)
void yyunput(int c, char *buf_ptr)
void yy_switch_to_buffer(yy_buffer_state *new_buffer)
void putback(char c)
Definition: flex-lexer.hh:149
virtual void switch_streams(std::istream *new_in=nullptr, std::ostream *new_out=nullptr)=0
vcsn::rat::location location
Definition: scan.hh:17
int yy_more_flag
Definition: flex-lexer.hh:220
void set_debug(int flag)
Definition: flex-lexer.hh:88