ddc
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 <iostream>
52 
53 extern "C++" {
54 
56  typedef int yy_state_type;
57 
58  class FlexLexer
59  {
60  public:
61  virtual ~FlexLexer() { }
62 
63  const char* YYText() const { return yytext; }
64  int YYLeng() const { return yyleng; }
65 
66  virtual void
67  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 yy_buffer_state* yy_create_buffer( std::istream& s, int size ) = 0;
70  virtual void yy_delete_buffer( yy_buffer_state* b ) = 0;
71  virtual void yyrestart( std::istream* s ) = 0;
72  virtual void yyrestart( std::istream& s ) = 0;
73 
74  virtual int yylex() = 0;
75 
76  // Call yylex with new input/output sources.
77  int yylex( std::istream& new_in, std::ostream& new_out )
78  {
79  switch_streams( new_in, new_out );
80  return yylex();
81  }
82 
83  int yylex( std::istream* new_in, std::ostream* new_out = 0)
84  {
85  switch_streams( new_in, new_out );
86  return yylex();
87  }
88 
89  // Switch to new input/output streams. A nil stream pointer
90  // indicates "keep the current one".
91  virtual void switch_streams( std::istream* new_in,
92  std::ostream* new_out ) = 0;
93  virtual void switch_streams( std::istream& new_in,
94  std::ostream& new_out ) = 0;
95 
96  int lineno() const { return yylineno; }
97 
98  int debug() const { return yy_flex_debug; }
99  void set_debug( int flag ) { yy_flex_debug = flag; }
100 
101  protected:
102  char* yytext;
103  int yyleng;
104  int yylineno; // only maintained if you use %option yylineno
105  int yy_flex_debug; // only has effect with -d or "%option debug"
106 
107  public:
108  int yybyteno; //-- moo: track absolute byte offset in input string (must be manually reset)
109  int byteno() { return yybyteno; }
110 
113 
116  };
117 
118 }
119 #endif // FLEXLEXER_H
120 
121 #if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
122 // Either this is the first time through (yyFlexLexerOnce not defined),
123 // or this is a repeated include to define a different flavor of
124 // yyFlexLexer, as discussed in the flex manual.
125 # define yyFlexLexerOnce
126 
127 extern "C++" {
128 
129  class yyFlexLexer : public FlexLexer {
130  public:
131  // arg_yyin and arg_yyout default to the cin and cout, but we
132  // only make that assignment when initializing in yylex().
133  yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout );
134  yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 );
135  private:
136  void ctor_common();
137 
138  public:
139 
140  virtual ~yyFlexLexer();
141 
142  void yy_switch_to_buffer( yy_buffer_state* new_buffer );
143  yy_buffer_state* yy_create_buffer( std::istream* s, int size );
144  yy_buffer_state* yy_create_buffer( std::istream& s, int size );
146  void yyrestart( std::istream* s );
147  void yyrestart( std::istream& s );
148 
149  void yypush_buffer_state( yy_buffer_state* new_buffer );
150  void yypop_buffer_state();
151 
152  virtual int yylex();
153  virtual void switch_streams( std::istream& new_in, std::ostream& new_out );
154  virtual void switch_streams( std::istream* new_in = 0, std::ostream* new_out = 0 );
155  virtual int yywrap();
156 
157  protected:
158  virtual int LexerInput( char* buf, int max_size );
159  virtual void LexerOutput( const char* buf, int size );
160  virtual void LexerError( const char* msg );
161 
162  void yyunput( int c, char* buf_ptr );
163  int yyinput();
164 
165  void yy_load_buffer_state();
166  void yy_init_buffer( yy_buffer_state* b, std::istream& s );
167  void yy_flush_buffer( yy_buffer_state* b );
168 
172 
173  void yy_begin( int new_state ); //-- moocow Mon, 06 Mar 2017 13:05:28 +0100: avoid stack ickiness
174  void yy_push_state( int new_state );
175  void yy_pop_state();
176  int yy_top_state();
177 
178  yy_state_type yy_get_previous_state();
179  yy_state_type yy_try_NUL_trans( yy_state_type current_state );
180  int yy_get_next_buffer();
181 
182  std::istream yyin; // input source for default LexerInput
183  std::ostream yyout; // output sink for default LexerOutput
184 
185  // yy_hold_char holds the character lost when yytext is formed.
187 
188  // Number of characters read into yy_ch_buf.
190 
191  // Points to current character in buffer.
192  char* yy_c_buf_p;
193 
194  int yy_init; // whether we need to initialize
195  int yy_start; // start state number
196 
197  // Flag which is used to allow yywrap()'s to do buffer switches
198  // instead of setting up a fresh yyin. A bit of a hack ...
200 
201 
205  void yyensure_buffer_stack(void);
206 
207  // The following are not always needed, but may be depending
208  // on use of certain flex features (like REJECT or yymore()).
209 
212 
215 
219 
220  int yy_lp;
222 
227  };
228 
229 }
230 
231 #endif // yyFlexLexer || ! yyFlexLexerOnce
232 
233 /*--- emacs style variables ---
234  * Local Variables:
235  * mode: C++
236  * c-file-style: "ellemtel"
237  * c-basic-offset: 4
238  * tab-width: 8
239  * indent-tabs-mode: nil
240  * End:
241  */
int yyDtrsPos
moo: byte-offset in query-string of active qf_subcorpora component, or -1 for none ...
Definition: FlexLexer.h:112
int yy_flex_debug
Definition: FlexLexer.h:105
int yy_start_stack_ptr
Definition: FlexLexer.h:169
virtual void yy_delete_buffer(yy_buffer_state *b)=0
yy_state_type * yy_state_ptr
Definition: FlexLexer.h:214
#define yyFlexLexer
Definition: QueryCompiler.h:34
int yylex(std::istream &new_in, std::ostream &new_out)
Definition: FlexLexer.h:77
size_t yy_buffer_stack_top
Definition: FlexLexer.h:202
int yy_prev_more_offset
Definition: FlexLexer.h:226
int byteno()
Definition: FlexLexer.h:109
int * yy_start_stack
Definition: FlexLexer.h:171
virtual void yyrestart(std::istream *s)=0
int yyleng
Definition: FlexLexer.h:103
yy_state_type * yy_state_buf
Definition: FlexLexer.h:213
int yy_full_lp
Definition: FlexLexer.h:218
std::istream yyin
Definition: FlexLexer.h:182
char yy_hold_char
Definition: FlexLexer.h:186
yy_state_type yy_last_accepting_state
Definition: FlexLexer.h:210
int yy_init
Definition: FlexLexer.h:194
int yy_more_offset
Definition: FlexLexer.h:225
int yyDtrsLen
moo: byte-length in query-string of active qf_subcorpora component, or 0 for none ...
Definition: FlexLexer.h:115
int yy_more_flag
Definition: FlexLexer.h:223
int yybyteno
Definition: FlexLexer.h:108
virtual int yylex()=0
char * yy_last_accepting_cpos
Definition: FlexLexer.h:211
virtual ~FlexLexer()
Definition: FlexLexer.h:61
int yy_state_type
Definition: FlexLexer.h:55
int yylineno
Definition: FlexLexer.h:104
int yy_looking_for_trail_begin
Definition: FlexLexer.h:221
char * yytext
Definition: FlexLexer.h:102
size_t yy_buffer_stack_max
Definition: FlexLexer.h:203
int yy_did_buffer_switch_on_eof
Definition: FlexLexer.h:199
Definition: FlexLexer.h:129
char * yy_full_match
Definition: FlexLexer.h:216
int lineno() const
Definition: FlexLexer.h:96
char * yy_c_buf_p
Definition: FlexLexer.h:192
Definition: yyQLexer.cpp:273
virtual yy_buffer_state * yy_create_buffer(std::istream *s, int size)=0
int * yy_full_state
Definition: FlexLexer.h:217
yy_buffer_state ** yy_buffer_stack
Definition: FlexLexer.h:204
int yy_start
Definition: FlexLexer.h:195
int yylex(std::istream *new_in, std::ostream *new_out=0)
Definition: FlexLexer.h:83
int yy_n_chars
Definition: FlexLexer.h:189
void set_debug(int flag)
Definition: FlexLexer.h:99
int yy_start_stack_depth
Definition: FlexLexer.h:170
const char * YYText() const
Definition: FlexLexer.h:63
std::ostream yyout
Definition: FlexLexer.h:183
int YYLeng() const
Definition: FlexLexer.h:64
int yy_lp
Definition: FlexLexer.h:220
int debug() const
Definition: FlexLexer.h:98
virtual void switch_streams(std::istream *new_in, std::ostream *new_out)=0
virtual void yy_switch_to_buffer(yy_buffer_state *new_buffer)=0
Definition: FlexLexer.h:58
int yy_more_len
Definition: FlexLexer.h:224