]> granicus.if.org Git - flex/commitdiff
mods so FlexLexer.h can be included separately
authorVern Paxson <vern@ee.lbl.gov>
Fri, 3 Dec 1993 12:49:45 +0000 (12:49 +0000)
committerVern Paxson <vern@ee.lbl.gov>
Fri, 3 Dec 1993 12:49:45 +0000 (12:49 +0000)
FlexLexer.h
flex.skl
main.c

index 571a6b78d5fecccf005fedb10a4f9b062cbf21ee..4427def62ccaf4a8c0e722e42cc4dfe598cdd604 100644 (file)
 // If you want to create multiple lexer classes, you use the -P flag
 // to rename each yyFlexLexer to some other xxFlexLexer.
 
+#include <iostream.h>
+
+struct yy_buffer_state;
+typedef int yy_state_type;
 
 class FlexLexer {
 public:
@@ -43,9 +47,11 @@ public:
        const char* YYText()    { return yytext; }
        int YYLeng()            { return yyleng; }
 
-       virtual void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) = 0;
-       virtual YY_BUFFER_STATE yy_create_buffer( istream* s, int size ) = 0;
-       virtual void yy_delete_buffer( YY_BUFFER_STATE b ) = 0;
+       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;
+       virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
        virtual void yyrestart( istream* s ) = 0;
 
        virtual int yylex() = 0;
@@ -88,9 +94,9 @@ public:
                delete yy_state_buf;
                }
 
-       void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer );
-       YY_BUFFER_STATE yy_create_buffer( istream* s, int size );
-       void yy_delete_buffer( YY_BUFFER_STATE b );
+       void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
+       struct yy_buffer_state* yy_create_buffer( istream* s, int size );
+       void yy_delete_buffer( struct yy_buffer_state* b );
        void yyrestart( istream* s );
 
        virtual int yylex();
@@ -103,7 +109,7 @@ protected:
        int yyinput();
 
        void yy_load_buffer_state();
-       void yy_init_buffer( YY_BUFFER_STATE b, istream* s );
+       void yy_init_buffer( struct yy_buffer_state* b, istream* s );
 
        yy_state_type yy_get_previous_state();
        yy_state_type yy_try_NUL_trans( yy_state_type current_state );
@@ -112,7 +118,7 @@ protected:
        istream* yyin;  // input source for default LexerInput
        ostream* yyout; // output sink for default LexerOutput
 
-       YY_BUFFER_STATE yy_current_buffer;
+       struct yy_buffer_state* yy_current_buffer;
 
        // yy_hold_char holds the character lost when yytext is formed.
        char yy_hold_char;
index 9894dc56a3e705696c8ee7f377860ed3144269b5..2dd5df87eb4d143e20eb8b92f0119d6d72cd6c6a 100644 (file)
--- a/flex.skl
+++ b/flex.skl
@@ -6,7 +6,9 @@
 
 #define FLEX_SCANNER
 
+%-
 #include <stdio.h>
+%*
 
 
 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
@@ -21,7 +23,7 @@
 
 #include <stdlib.h>
 %+
-#include <iostream.h>
+class istream;
 %*
 #include <unistd.h>
 
diff --git a/main.c b/main.c
index 73981d60dd965941d972a3e3aa87a7c3ebc8387f..8e9d10852a50fe8961b18f703bff1d4cbe1b4bd3 100644 (file)
--- a/main.c
+++ b/main.c
@@ -677,13 +677,16 @@ char **argv;
                }
 
        if ( (fulltbl || fullspd) && usemecs )
-               flexerror( "-f/-F and -Cm don't make sense together" );
+               flexerror( "-Cf/-CF and -Cm don't make sense together" );
 
        if ( (fulltbl || fullspd) && interactive )
-               flexerror( "-f/-F and -I are incompatible" );
+               flexerror( "-Cf/-CF and -I are incompatible" );
 
        if ( fulltbl && fullspd )
-               flexerror( "-f and -F are mutually exclusive" );
+               flexerror( "-Cf and -CF are mutually exclusive" );
+
+       if ( C_plus_plus && fullspd )
+               flexerror( "Can't use -+ with -CF option" );
 
        if ( ! use_stdout )
                {
@@ -830,7 +833,7 @@ void readin()
        if ( fullspd )
                printf(
                "typedef const struct yy_trans_info *yy_state_type;\n" );
-       else
+       else if ( ! C_plus_plus )
                printf( "typedef int yy_state_type;\n" );
 
        if ( reject )
@@ -845,7 +848,7 @@ void readin()
                printf( "extern int yylineno;\n" );
                printf( "int yylineno = 1;\n" );
                }
-       else
+       else if ( ! C_plus_plus )
                printf( "FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;\n" );
 
        if ( C_plus_plus )