From cd0e94e833e69b7b52210125b74f2728bdbb2afb Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Tue, 7 Dec 1993 10:11:41 +0000 Subject: [PATCH] Support for yyFlexLexer::LexerError --- FlexLexer.h | 1 + flex.skl | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/FlexLexer.h b/FlexLexer.h index 4427def..f1616b4 100644 --- a/FlexLexer.h +++ b/FlexLexer.h @@ -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(); diff --git a/flex.skl b/flex.skl index 62597cc..336fdec 100644 --- 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. */ -- 2.50.0