]> granicus.if.org Git - flex/commitdiff
Support for yyFlexLexer::LexerError
authorVern Paxson <vern@ee.lbl.gov>
Tue, 7 Dec 1993 10:11:41 +0000 (10:11 +0000)
committerVern Paxson <vern@ee.lbl.gov>
Tue, 7 Dec 1993 10:11:41 +0000 (10:11 +0000)
FlexLexer.h
flex.skl

index 4427def62ccaf4a8c0e722e42cc4dfe598cdd604..f1616b47cd274257b11429877f1a32f9876ca88b 100644 (file)
@@ -104,6 +104,7 @@ public:
 protected:
        virtual int LexerInput( char* buf, int max_size );
        virtual void LexerOutput( const char* buf, int size );
+       virtual void LexerError( const char* msg );
 
        void yyunput( int c, char* buf_ptr );
        int yyinput();
index 62597ccbb420a7fd6e9682f3bb40ec4401c826aa..336fdec5331fc9d0e12f32672255fbcc59298d61 100644 (file)
--- a/flex.skl
+++ b/flex.skl
@@ -296,7 +296,11 @@ static void yy_fatal_error YY_PROTO(( const char msg[] ));
 
 /* Report a fatal error. */
 #ifndef YY_FATAL_ERROR
+%-
 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+%+
+#define YY_FATAL_ERROR(msg) LexerError( msg )
+%*
 #endif
 
 /* Default declaration of generated scanner - a define so the user can
@@ -514,13 +518,6 @@ do_action: /* This label is used only to access EOF actions. */
                }
 
        default:
-#ifdef FLEX_DEBUG
-%-
-               printf( "action # %d\n", yy_act );
-%+
-               cout << "action # " << yy_act << '\n';
-%*
-#endif
                YY_FATAL_ERROR(
                        "fatal flex scanner internal error--no action found" );
        } /* end of action switch */
@@ -1009,6 +1006,7 @@ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
        }
 
 
+%-
 #ifdef YY_USE_PROTOS
 static void yy_fatal_error( const char msg[] )
 #else
@@ -1016,13 +1014,18 @@ static void yy_fatal_error( msg )
 char msg[];
 #endif
        {
-%-
        (void) fprintf( stderr, "%s\n", msg );
+       exit( 1 );
+       }
+
 %+
+
+void yyFlexLexer::LexerError( const char msg[] )
+       {
        cerr << msg << '\n';
-%*
        exit( 1 );
        }
+%*
 
 
 /* Redefine yyless() so it works in section 3 code. */