OmniSciDB  a667adc9c8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FlexLexer_wnd.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  public:
60  virtual ~FlexLexer() {}
61 
62  const char* YYText() const { return yytext; }
63  int YYLeng() const { return yyleng; }
64 
65  virtual void yy_switch_to_buffer(yy_buffer_state* new_buffer) = 0;
66  virtual yy_buffer_state* yy_create_buffer(std::istream* s, int size) = 0;
67  virtual yy_buffer_state* yy_create_buffer(std::istream& s, int size) = 0;
68  virtual void yy_delete_buffer(yy_buffer_state* b) = 0;
69  virtual void yyrestart(std::istream* s) = 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) {
76  switch_streams(new_in, new_out);
77  return yylex();
78  }
79 
80  int yylex(std::istream* new_in, std::ostream* new_out = 0) {
81  switch_streams(new_in, new_out);
82  return yylex();
83  }
84 
85  // Switch to new input/output streams. A nil stream pointer
86  // indicates "keep the current one".
87  virtual void switch_streams(std::istream* new_in, std::ostream* new_out) = 0;
88  virtual void switch_streams(std::istream& new_in, std::ostream& new_out) = 0;
89 
90  int lineno() const { return yylineno; }
91 
92  int debug() const { return yy_flex_debug; }
93  void set_debug(int flag) { yy_flex_debug = flag; }
94 
95  protected:
96  char* yytext;
97  int yyleng;
98  int yylineno; // only maintained if you use %option yylineno
99  int yy_flex_debug; // only has effect with -d or "%option debug"
100 };
101 }
102 #endif // FLEXLEXER_H
103 
104 #if defined(yyFlexLexer) || !defined(yyFlexLexerOnce)
105 // Either this is the first time through (yyFlexLexerOnce not defined),
106 // or this is a repeated include to define a different flavor of
107 // yyFlexLexer, as discussed in the flex manual.
108 #define yyFlexLexerOnce
109 
110 extern "C++" {
111 
112 class yyFlexLexer : public FlexLexer {
113  public:
114  // arg_yyin and arg_yyout default to the cin and cout, but we
115  // only make that assignment when initializing in yylex().
116  yyFlexLexer(std::istream& arg_yyin, std::ostream& arg_yyout);
117  yyFlexLexer(std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0);
118 
119  private:
120  void ctor_common();
121 
122  public:
123  virtual ~yyFlexLexer();
124 
125  void yy_switch_to_buffer(yy_buffer_state* new_buffer);
126  yy_buffer_state* yy_create_buffer(std::istream* s, int size);
127  yy_buffer_state* yy_create_buffer(std::istream& s, int size);
129  void yyrestart(std::istream* s);
130  void yyrestart(std::istream& s);
131 
132  void yypush_buffer_state(yy_buffer_state* new_buffer);
133  void yypop_buffer_state();
134 
135  virtual int yylex();
136  virtual void switch_streams(std::istream& new_in, std::ostream& new_out);
137  virtual void switch_streams(std::istream* new_in = 0, std::ostream* new_out = 0);
138  virtual int yywrap();
139 
140  protected:
141  virtual int LexerInput(char* buf, int max_size);
142  virtual void LexerOutput(const char* buf, int size);
143  virtual void LexerError(const char* msg);
144 
145  void yyunput(int c, char* buf_ptr);
146  int yyinput();
147 
148  void yy_load_buffer_state();
149  void yy_init_buffer(yy_buffer_state* b, std::istream& s);
151 
155 
156  void yy_push_state(int new_state);
157  void yy_pop_state();
158  int yy_top_state();
159 
162  int yy_get_next_buffer();
163 
164  std::istream yyin; // input source for default LexerInput
165  std::ostream yyout; // output sink for default LexerOutput
166 
167  // yy_hold_char holds the character lost when yytext is formed.
169 
170  // Number of characters read into yy_ch_buf.
172 
173  // Points to current character in buffer.
174  char* yy_c_buf_p;
175 
176  int yy_init; // whether we need to initialize
177  int yy_start; // start state number
178 
179  // Flag which is used to allow yywrap()'s to do buffer switches
180  // instead of setting up a fresh yyin. A bit of a hack ...
182 
186  void yyensure_buffer_stack(void);
187 
188  // The following are not always needed, but may be depending
189  // on use of certain flex features (like REJECT or yymore()).
190 
193 
196 
200 
201  int yy_lp;
203 
208 };
209 }
210 
211 #endif // yyFlexLexer || ! yyFlexLexerOnce
int yylex(std::istream *new_in, std::ostream *new_out=0)
Definition: FlexLexer_wnd.h:80
std::istream yyin
virtual void yyrestart(std::istream *s)=0
virtual ~FlexLexer()
Definition: FlexLexer_wnd.h:60
void yy_flush_buffer(yy_buffer_state *b)
char * yytext
Definition: FlexLexer_wnd.h:96
void yyrestart(std::istream *s)
void yy_push_state(int new_state)
int yy_top_state()
size_t yy_buffer_stack_top
size_t yy_buffer_stack_max
int yy_did_buffer_switch_on_eof
int lineno() const
Definition: FlexLexer_wnd.h:90
yy_state_type yy_last_accepting_state
virtual int yylex()
int yy_start_stack_ptr
int yy_get_next_buffer()
void yy_load_buffer_state()
yy_state_type * yy_state_ptr
void yypush_buffer_state(yy_buffer_state *new_buffer)
yyFlexLexer(std::istream &arg_yyin, std::ostream &arg_yyout)
virtual void yy_switch_to_buffer(yy_buffer_state *new_buffer)=0
const char * YYText() const
Definition: FlexLexer_wnd.h:62
yy_state_type yy_get_previous_state()
void yy_switch_to_buffer(yy_buffer_state *new_buffer)
int YYLeng() const
Definition: FlexLexer_wnd.h:63
int debug() const
Definition: FlexLexer_wnd.h:92
void set_debug(int flag)
Definition: FlexLexer_wnd.h:93
int * yy_full_state
void ctor_common()
char * yy_last_accepting_cpos
virtual void LexerOutput(const char *buf, int size)
virtual void LexerError(const char *msg)
char * yy_c_buf_p
yy_buffer_state * yy_create_buffer(std::istream *s, int size)
void yyunput(int c, char *buf_ptr)
virtual int yywrap()
void yy_init_buffer(yy_buffer_state *b, std::istream &s)
int * yy_start_stack
int yy_state_type
Definition: FlexLexer_wnd.h:55
virtual void switch_streams(std::istream &new_in, std::ostream &new_out)
int yy_flex_debug
Definition: FlexLexer_wnd.h:99
void yy_pop_state()
int yy_looking_for_trail_begin
void yypop_buffer_state()
yy_state_type * yy_state_buf
int yy_start_stack_depth
virtual void yy_delete_buffer(yy_buffer_state *b)=0
virtual void switch_streams(std::istream *new_in, std::ostream *new_out)=0
virtual ~yyFlexLexer()
virtual int LexerInput(char *buf, int max_size)
yy_buffer_state ** yy_buffer_stack
int yylex(std::istream &new_in, std::ostream &new_out)
Definition: FlexLexer_wnd.h:75
void yyensure_buffer_stack(void)
virtual int yylex()=0
virtual yy_buffer_state * yy_create_buffer(std::istream *s, int size)=0
char * yy_full_match
int yy_prev_more_offset
yy_state_type yy_try_NUL_trans(yy_state_type current_state)
void yy_delete_buffer(yy_buffer_state *b)
std::ostream yyout