torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bitstream/assembler/lut/FlexLexer.h
Go to the documentation of this file.
1 // -*-C++-*-
2 // CFlexLexer.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 CFlexLexer, 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 #include <string>
53 # ifndef FLEX_STD
54 # define FLEX_STD std::
55 # endif
56 
57 extern "C++" {
58 
60 typedef int yy_state_type;
61 
62 class FlexLexer {
63 public:
64  virtual ~FlexLexer() { }
65 
66  const char* YYText() const { return yytext; }
67  int YYLeng() const { return yyleng; }
68 
69  virtual void
70  yy_switch_to_buffer(struct yy_buffer_state* new_buffer) = 0;
71  virtual struct yy_buffer_state*
72  yy_create_buffer(FLEX_STD istream* s, int size) = 0;
73  virtual void yy_delete_buffer(struct yy_buffer_state* b) = 0;
74  virtual void yyrestart(FLEX_STD istream* s) = 0;
75 
76  virtual int yylex() = 0;
77 
78  // Call yylex with new input/output sources.
79  int yylex(FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0)
80  {
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(FLEX_STD istream* new_in = 0,
88  FLEX_STD ostream* new_out = 0) = 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 }
103 #endif // FLEXLEXER_H
104 
105 #if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
106 // Either this is the first time through (yyFlexLexerOnce not defined),
107 // or this is a repeated include to define a different flavor of
108 // yyFlexLexer, as discussed in the flex manual.
109 #define yyFlexLexerOnce
110 
111 extern "C++" {
112 
113 class yyFlexLexer : public FlexLexer
114 {
115 public:
116  // arg_yyin and arg_yyout default to the cin and cout, but we
117  // only make that assignment when initializing in yylex().
118  yyFlexLexer(FLEX_STD istream* arg_yyin = 0,
119  FLEX_STD ostream* arg_yyout = 0);
120 
121  virtual ~yyFlexLexer();
122 
123  void yy_switch_to_buffer(struct yy_buffer_state* new_buffer);
124  struct yy_buffer_state* yy_create_buffer(FLEX_STD istream* s, int size);
125  void yy_delete_buffer(struct yy_buffer_state* b);
126  void yyrestart(FLEX_STD istream* s);
127 
128  void yypush_buffer_state(struct yy_buffer_state* new_buffer);
129  void yypop_buffer_state();
130 
131  virtual int yylex();
132  virtual void switch_streams(FLEX_STD istream* new_in,
133  FLEX_STD ostream* new_out);
134 
135  // This fixes a compatibility problem between source generated by flex
136  // 2.5.34 and 2.5.35: always define yywrap as a virtual function.
137  virtual int yywrap();
138 
139 protected:
140  virtual int LexerInput(char* buf, int max_size);
141  virtual void LexerOutput(const char* buf, int size);
142  virtual void LexerError(const char* msg);
143 
144  void yyunput(int c, char* buf_ptr);
145  int yyinput();
146 
147  void yy_load_buffer_state();
148  void yy_init_buffer(struct yy_buffer_state* b, FLEX_STD istream* s);
149  void yy_flush_buffer(struct yy_buffer_state* b);
150 
154 
155  void yy_push_state(int new_state);
156  void yy_pop_state();
157  int yy_top_state();
158 
161  int yy_get_next_buffer();
162 
163  FLEX_STD istream* yyin; // input source for default LexerInput
164  FLEX_STD ostream* yyout; // output sink for default LexerOutput
165 
166  // yy_hold_char holds the character lost when yytext is formed.
168 
169  // Number of characters read into yy_ch_buf.
171 
172  // Points to current character in buffer.
173  char* yy_c_buf_p;
174 
175  int yy_init; // whether we need to initialize
176  int yy_start; // start state number
177 
178  // Flag which is used to allow yywrap()'s to do buffer switches
179  // instead of setting up a fresh yyin. A bit of a hack ...
181 
182 
183  size_t yy_buffer_stack_top; /**< index of top of stack. */
184  size_t yy_buffer_stack_max; /**< capacity of stack. */
185  struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
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 } // extern "C++"
211 
212 #endif // yyFlexLexer || ! yyFlexLexerOnce
virtual int yylex()
void yy_switch_to_buffer(struct yy_buffer_state *new_buffer)
virtual void switch_streams(FLEX_STD istream *new_in=0, FLEX_STD ostream *new_out=0)=0
void yypush_buffer_state(struct yy_buffer_state *new_buffer)
void yy_push_state(int new_state)
yy_state_type yy_try_NUL_trans(yy_state_type current_state)
virtual void yy_switch_to_buffer(struct yy_buffer_state *new_buffer)=0
void yy_flush_buffer(struct yy_buffer_state *b)
const char * YYText() const
struct yy_buffer_state * yy_create_buffer(FLEX_STD istream *s, int size)
void yyunput(int c, char *buf_ptr)
void yypop_buffer_state()
virtual void LexerError(const char *msg)
virtual int yylex()=0
void yy_load_buffer_state()
yyFlexLexer(FLEX_STD istream *arg_yyin=0, FLEX_STD ostream *arg_yyout=0)
struct yy_buffer_state ** yy_buffer_stack
virtual int LexerInput(char *buf, int max_size)
Definition: LutScanner.cpp:930
virtual struct yy_buffer_state * yy_create_buffer(FLEX_STD istream *s, int size)=0
virtual void LexerOutput(const char *buf, int size)
Definition: LutScanner.cpp:957
Bison parser internals.
Definition: LutScanner.cpp:198
int yy_get_next_buffer()
Definition: LutScanner.cpp:969
void yyensure_buffer_stack(void)
virtual void yyrestart(FLEX_STD istream *s)=0
int yylex(FLEX_STD istream *new_in, FLEX_STD ostream *new_out=0)
void yyrestart(FLEX_STD istream *s)
void yy_delete_buffer(struct yy_buffer_state *b)
int yy_top_state()
virtual void switch_streams(FLEX_STD istream *new_in, FLEX_STD ostream *new_out)
virtual void yy_delete_buffer(struct yy_buffer_state *b)=0
void yy_pop_state()
void yy_init_buffer(struct yy_buffer_state *b, FLEX_STD istream *s)
yy_state_type yy_get_previous_state()
virtual int yywrap()
virtual ~yyFlexLexer()
Definition: LutScanner.cpp:905