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