[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
flex patches for ISO C++ compilers
From: |
Curtis L. Janssen |
Subject: |
flex patches for ISO C++ compilers |
Date: |
Tue, 7 Aug 2001 13:04:45 -0700 (PDT) |
The patches below allow flex-2.5.4a to support ISO C++ compilers.
These patches work with GCC 3.0, IBM C++ 5.0, and Compaq C++
6.3.6.8. The following problems are fixed:
o Illegal use of delete (changed to delete[])
o Namespace fixes
o Include <iostream> instead of <iostream.h> (this is necessary
since <iostream.h> isn't required by ISO C++ and even
compilers that provide iostream.h sometimes have serious
problems when both <iostream.h> and <iostream> are included)
For backwards compatibility to very old C++ compilers
-DFLEX_IOSTREAM_H can be specified.
These patches are a substitute rather than an addition to the
other C++ patches that have appeared on the help-flex list. The
patches below fix problems missed by the other patch.
Curt
-----------------------------------------------------------------------
diff -u flex-2.5.4/FlexLexer.h flex-2.5.4-snl/FlexLexer.h
--- flex-2.5.4/FlexLexer.h Sat Jul 26 19:41:38 1997
+++ flex-2.5.4-snl/FlexLexer.h Thu Mar 15 08:58:21 2001
@@ -44,7 +44,17 @@
#ifndef __FLEX_LEXER_H
// Never included before - need to define base class.
#define __FLEX_LEXER_H
-#include <iostream.h>
+#ifdef FLEX_IOSTREAM_H
+# include <iostream.h>
+# ifndef FLEX_STD
+# define FLEX_STD
+# endif
+#else
+# include <iostream>
+# ifndef FLEX_STD
+# define FLEX_STD std::
+# endif
+#endif
extern "C++" {
@@ -61,14 +71,14 @@
virtual void
yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
virtual struct yy_buffer_state*
- yy_create_buffer( istream* s, int size ) = 0;
+ yy_create_buffer( FLEX_STD istream* s, int size ) = 0;
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
- virtual void yyrestart( istream* s ) = 0;
+ virtual void yyrestart( FLEX_STD istream* s ) = 0;
virtual int yylex() = 0;
// Call yylex with new input/output sources.
- int yylex( istream* new_in, ostream* new_out = 0 )
+ int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 )
{
switch_streams( new_in, new_out );
return yylex();
@@ -76,8 +86,8 @@
// Switch to new input/output streams. A nil stream pointer
// indicates "keep the current one".
- virtual void switch_streams( istream* new_in = 0,
- ostream* new_out = 0 ) = 0;
+ virtual void switch_streams( FLEX_STD istream* new_in = 0,
+ FLEX_STD ostream* new_out = 0 ) = 0;
int lineno() const { return yylineno; }
@@ -104,17 +114,20 @@
public:
// arg_yyin and arg_yyout default to the cin and cout, but we
// only make that assignment when initializing in yylex().
- yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 );
+ yyFlexLexer( FLEX_STD istream* arg_yyin = 0,
+ FLEX_STD ostream* arg_yyout = 0 );
virtual ~yyFlexLexer();
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
- struct yy_buffer_state* yy_create_buffer( istream* s, int size );
+ struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s,
+ int size );
void yy_delete_buffer( struct yy_buffer_state* b );
- void yyrestart( istream* s );
+ void yyrestart( FLEX_STD istream* s );
virtual int yylex();
- virtual void switch_streams( istream* new_in, ostream* new_out );
+ virtual void switch_streams( FLEX_STD istream* new_in,
+ FLEX_STD ostream* new_out );
protected:
virtual int LexerInput( char* buf, int max_size );
@@ -125,7 +138,7 @@
int yyinput();
void yy_load_buffer_state();
- void yy_init_buffer( struct yy_buffer_state* b, istream* s );
+ void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s );
void yy_flush_buffer( struct yy_buffer_state* b );
int yy_start_stack_ptr;
@@ -140,8 +153,8 @@
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
int yy_get_next_buffer();
- istream* yyin; // input source for default LexerInput
- ostream* yyout; // output sink for default LexerOutput
+ FLEX_STD istream* yyin; // input source for default LexerInput
+ FLEX_STD ostream* yyout; // output sink for default LexerOutput
struct yy_buffer_state* yy_current_buffer;
Common subdirectories: flex-2.5.4/MISC and flex-2.5.4-snl/MISC
diff -u flex-2.5.4/flex.skl flex-2.5.4-snl/flex.skl
--- flex-2.5.4/flex.skl Tue Sep 10 16:58:54 1996
+++ flex-2.5.4-snl/flex.skl Thu Mar 15 08:50:33 2001
@@ -677,7 +677,7 @@
yyFlexLexer::~yyFlexLexer()
{
- delete yy_state_buf;
+ delete[] yy_state_buf;
yy_delete_buffer( yy_current_buffer );
}
diff -u flex-2.5.4/skel.c flex-2.5.4-snl/skel.c
--- flex-2.5.4/skel.c Tue Sep 10 17:00:38 1996
+++ flex-2.5.4-snl/skel.c Thu Mar 15 08:51:17 2001
@@ -682,7 +682,7 @@
"",
"yyFlexLexer::~yyFlexLexer()",
" {",
- " delete yy_state_buf;",
+ " delete[] yy_state_buf;",
" yy_delete_buffer( yy_current_buffer );",
" }",
"",
-----------------------------------------------------------------------
Curtis Janssen
address@hidden http://aros.ca.sandia.gov/~cljanss
Tel: +1 925-294-1509 Fax: +1 925-294-2234
Sandia National Labs, MS 9217, PO Box 969, Livermore, CA 94551, USA
- flex patches for ISO C++ compilers,
Curtis L. Janssen <=