Jon West | a34208a | 2018-08-22 10:49:04 -0400 | [diff] [blame] | 1 | From e6c2552e60db1443867762dd62f51f9370dfb23d Mon Sep 17 00:00:00 2001 |
| 2 | From: Steven Moreland <smoreland@google.com> |
| 3 | Date: Thu, 31 May 2018 14:38:54 -0700 |
| 4 | Subject: [PATCH] Revert "Update FlexLinker.h to current version of flex." |
| 5 | |
| 6 | This reverts commit a0a36870d5b5a66b7f7d04ea1aa15488b396d42d. |
| 7 | --- |
| 8 | include/mcld/Script/FlexLexer.h | 133 ++++++++++++++------------------ |
| 9 | 1 file changed, 56 insertions(+), 77 deletions(-) |
| 10 | |
| 11 | diff --git a/include/mcld/Script/FlexLexer.h b/include/mcld/Script/FlexLexer.h |
| 12 | index cbc95f9..3514ee1 100644 |
| 13 | --- a/include/mcld/Script/FlexLexer.h |
| 14 | +++ b/include/mcld/Script/FlexLexer.h |
| 15 | @@ -44,141 +44,122 @@ |
| 16 | // to rename each yyFlexLexer to some other xxFlexLexer. You then |
| 17 | // include <FlexLexer.h> in your other sources once per lexer class: |
| 18 | // |
| 19 | -// #undef yyFlexLexer |
| 20 | -// #define yyFlexLexer xxFlexLexer |
| 21 | -// #include <FlexLexer.h> |
| 22 | +// #undef yyFlexLexer |
| 23 | +// #define yyFlexLexer xxFlexLexer |
| 24 | +// #include <FlexLexer.h> |
| 25 | // |
| 26 | -// #undef yyFlexLexer |
| 27 | -// #define yyFlexLexer zzFlexLexer |
| 28 | -// #include <FlexLexer.h> |
| 29 | -// ... |
| 30 | +// #undef yyFlexLexer |
| 31 | +// #define yyFlexLexer zzFlexLexer |
| 32 | +// #include <FlexLexer.h> |
| 33 | +// ... |
| 34 | |
| 35 | #ifndef __FLEX_LEXER_H |
| 36 | // Never included before - need to define base class. |
| 37 | #define __FLEX_LEXER_H |
| 38 | |
| 39 | #include <iostream> |
| 40 | +#ifndef FLEX_STD |
| 41 | +#define FLEX_STD std:: |
| 42 | +#endif |
| 43 | |
| 44 | extern "C++" { |
| 45 | - |
| 46 | struct yy_buffer_state; |
| 47 | typedef int yy_state_type; |
| 48 | |
| 49 | -class FlexLexer |
| 50 | -{ |
| 51 | -public: |
| 52 | - virtual ~FlexLexer() { } |
| 53 | +class FlexLexer { |
| 54 | + public: |
| 55 | + virtual ~FlexLexer() {} |
| 56 | |
| 57 | - const char* YYText() const { return yytext; } |
| 58 | - int YYLeng() const { return yyleng; } |
| 59 | + const char* YYText() const { return yytext; } |
| 60 | + int YYLeng() const { return yyleng; } |
| 61 | |
| 62 | - virtual void |
| 63 | - yy_switch_to_buffer( yy_buffer_state* new_buffer ) = 0; |
| 64 | - virtual yy_buffer_state* yy_create_buffer( std::istream* s, int size ) = 0; |
| 65 | - virtual yy_buffer_state* yy_create_buffer( std::istream& s, int size ) = 0; |
| 66 | - virtual void yy_delete_buffer( yy_buffer_state* b ) = 0; |
| 67 | - virtual void yyrestart( std::istream* s ) = 0; |
| 68 | - virtual void yyrestart( std::istream& s ) = 0; |
| 69 | + virtual void yy_switch_to_buffer(struct yy_buffer_state* new_buffer) = 0; |
| 70 | + virtual struct yy_buffer_state* yy_create_buffer(FLEX_STD istream* s, |
| 71 | + int size) = 0; |
| 72 | + virtual void yy_delete_buffer(struct yy_buffer_state* b) = 0; |
| 73 | + virtual void yyrestart(FLEX_STD istream* s) = 0; |
| 74 | |
| 75 | virtual int yylex() = 0; |
| 76 | |
| 77 | // Call yylex with new input/output sources. |
| 78 | - int yylex( std::istream& new_in, std::ostream& new_out ) |
| 79 | - { |
| 80 | - switch_streams( new_in, new_out ); |
| 81 | - return yylex(); |
| 82 | - } |
| 83 | - |
| 84 | - int yylex( std::istream* new_in, std::ostream* new_out = 0) |
| 85 | - { |
| 86 | - switch_streams( new_in, new_out ); |
| 87 | + int yylex(FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0) { |
| 88 | + switch_streams(new_in, new_out); |
| 89 | return yylex(); |
| 90 | } |
| 91 | |
| 92 | // Switch to new input/output streams. A nil stream pointer |
| 93 | // indicates "keep the current one". |
| 94 | - virtual void switch_streams( std::istream* new_in, |
| 95 | - std::ostream* new_out ) = 0; |
| 96 | - virtual void switch_streams( std::istream& new_in, |
| 97 | - std::ostream& new_out ) = 0; |
| 98 | + virtual void switch_streams(FLEX_STD istream* new_in = 0, |
| 99 | + FLEX_STD ostream* new_out = 0) = 0; |
| 100 | |
| 101 | - int lineno() const { return yylineno; } |
| 102 | + int lineno() const { return yylineno; } |
| 103 | |
| 104 | - int debug() const { return yy_flex_debug; } |
| 105 | - void set_debug( int flag ) { yy_flex_debug = flag; } |
| 106 | + int debug() const { return yy_flex_debug; } |
| 107 | + void set_debug(int flag) { yy_flex_debug = flag; } |
| 108 | |
| 109 | -protected: |
| 110 | + protected: |
| 111 | char* yytext; |
| 112 | int yyleng; |
| 113 | int yylineno; // only maintained if you use %option yylineno |
| 114 | int yy_flex_debug; // only has effect with -d or "%option debug" |
| 115 | }; |
| 116 | - |
| 117 | } |
| 118 | -#endif // FLEXLEXER_H |
| 119 | +#endif // FLEXLEXER_H |
| 120 | |
| 121 | -#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) |
| 122 | +#if defined(yyFlexLexer) || !defined(yyFlexLexerOnce) |
| 123 | // Either this is the first time through (yyFlexLexerOnce not defined), |
| 124 | // or this is a repeated include to define a different flavor of |
| 125 | // yyFlexLexer, as discussed in the flex manual. |
| 126 | -# define yyFlexLexerOnce |
| 127 | +#define yyFlexLexerOnce |
| 128 | |
| 129 | extern "C++" { |
| 130 | - |
| 131 | class yyFlexLexer : public FlexLexer { |
| 132 | -public: |
| 133 | + public: |
| 134 | // arg_yyin and arg_yyout default to the cin and cout, but we |
| 135 | // only make that assignment when initializing in yylex(). |
| 136 | - yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ); |
| 137 | - yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 ); |
| 138 | -private: |
| 139 | - void ctor_common(); |
| 140 | - |
| 141 | -public: |
| 142 | + yyFlexLexer(FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0); |
| 143 | |
| 144 | virtual ~yyFlexLexer(); |
| 145 | |
| 146 | - void yy_switch_to_buffer( yy_buffer_state* new_buffer ); |
| 147 | - yy_buffer_state* yy_create_buffer( std::istream* s, int size ); |
| 148 | - yy_buffer_state* yy_create_buffer( std::istream& s, int size ); |
| 149 | - void yy_delete_buffer( yy_buffer_state* b ); |
| 150 | - void yyrestart( std::istream* s ); |
| 151 | - void yyrestart( std::istream& s ); |
| 152 | + void yy_switch_to_buffer(struct yy_buffer_state* new_buffer); |
| 153 | + struct yy_buffer_state* yy_create_buffer(FLEX_STD istream* s, int size); |
| 154 | + void yy_delete_buffer(struct yy_buffer_state* b); |
| 155 | + void yyrestart(FLEX_STD istream* s); |
| 156 | |
| 157 | - void yypush_buffer_state( yy_buffer_state* new_buffer ); |
| 158 | + void yypush_buffer_state(struct yy_buffer_state* new_buffer); |
| 159 | void yypop_buffer_state(); |
| 160 | |
| 161 | virtual int yylex(); |
| 162 | - virtual void switch_streams( std::istream& new_in, std::ostream& new_out ); |
| 163 | - virtual void switch_streams( std::istream* new_in = 0, std::ostream* new_out = 0 ); |
| 164 | + virtual void switch_streams(FLEX_STD istream* new_in, |
| 165 | + FLEX_STD ostream* new_out = 0); |
| 166 | virtual int yywrap(); |
| 167 | |
| 168 | -protected: |
| 169 | - virtual int LexerInput( char* buf, int max_size ); |
| 170 | - virtual void LexerOutput( const char* buf, int size ); |
| 171 | - virtual void LexerError( const char* msg ); |
| 172 | + protected: |
| 173 | + virtual int LexerInput(char* buf, int max_size); |
| 174 | + virtual void LexerOutput(const char* buf, int size); |
| 175 | + virtual void LexerError(const char* msg); |
| 176 | |
| 177 | - void yyunput( int c, char* buf_ptr ); |
| 178 | + void yyunput(int c, char* buf_ptr); |
| 179 | int yyinput(); |
| 180 | |
| 181 | void yy_load_buffer_state(); |
| 182 | - void yy_init_buffer( yy_buffer_state* b, std::istream& s ); |
| 183 | - void yy_flush_buffer( yy_buffer_state* b ); |
| 184 | + void yy_init_buffer(struct yy_buffer_state* b, FLEX_STD istream* s); |
| 185 | + void yy_flush_buffer(struct yy_buffer_state* b); |
| 186 | |
| 187 | int yy_start_stack_ptr; |
| 188 | int yy_start_stack_depth; |
| 189 | int* yy_start_stack; |
| 190 | |
| 191 | - void yy_push_state( int new_state ); |
| 192 | + void yy_push_state(int new_state); |
| 193 | void yy_pop_state(); |
| 194 | int yy_top_state(); |
| 195 | |
| 196 | yy_state_type yy_get_previous_state(); |
| 197 | - yy_state_type yy_try_NUL_trans( yy_state_type current_state ); |
| 198 | + yy_state_type yy_try_NUL_trans(yy_state_type current_state); |
| 199 | int yy_get_next_buffer(); |
| 200 | |
| 201 | - std::istream yyin; // input source for default LexerInput |
| 202 | - std::ostream yyout; // output sink for default LexerOutput |
| 203 | + FLEX_STD istream* yyin; // input source for default LexerInput |
| 204 | + FLEX_STD ostream* yyout; // output sink for default LexerOutput |
| 205 | |
| 206 | // yy_hold_char holds the character lost when yytext is formed. |
| 207 | char yy_hold_char; |
| 208 | @@ -189,17 +170,16 @@ protected: |
| 209 | // Points to current character in buffer. |
| 210 | char* yy_c_buf_p; |
| 211 | |
| 212 | - int yy_init; // whether we need to initialize |
| 213 | - int yy_start; // start state number |
| 214 | + int yy_init; // whether we need to initialize |
| 215 | + int yy_start; // start state number |
| 216 | |
| 217 | // Flag which is used to allow yywrap()'s to do buffer switches |
| 218 | // instead of setting up a fresh yyin. A bit of a hack ... |
| 219 | int yy_did_buffer_switch_on_eof; |
| 220 | |
| 221 | - |
| 222 | - size_t yy_buffer_stack_top; /**< index of top of stack. */ |
| 223 | - size_t yy_buffer_stack_max; /**< capacity of stack. */ |
| 224 | - yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */ |
| 225 | + size_t yy_buffer_stack_top; /**< index of top of stack. */ |
| 226 | + size_t yy_buffer_stack_max; /**< capacity of stack. */ |
| 227 | + struct yy_buffer_state** yy_buffer_stack; /**< Stack as an array. */ |
| 228 | void yyensure_buffer_stack(void); |
| 229 | |
| 230 | // The following are not always needed, but may be depending |
| 231 | @@ -223,7 +203,6 @@ protected: |
| 232 | int yy_more_offset; |
| 233 | int yy_prev_more_offset; |
| 234 | }; |
| 235 | - |
| 236 | } |
| 237 | |
| 238 | #endif // yyFlexLexer || ! yyFlexLexerOnce |
| 239 | -- |
| 240 | 2.17.1 |
| 241 | |