From 151339baea2fa878f41e7f12b4db9effc59197aa Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Mon, 4 Oct 1993 10:17:40 +0000 Subject: [PATCH] Added yy_fatal_error function. --- flex.skl | 59 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/flex.skl b/flex.skl index afb7857..1590b6d 100644 --- a/flex.skl +++ b/flex.skl @@ -103,33 +103,8 @@ #define YY_NULL 0 /* Report a fatal error. */ - -/* The funky do-while is used to turn this macro definition into - * a single C statement (which needs a semi-colon terminator). - * This avoids problems with code like: - * - * if ( something_happens ) - * YY_FATAL_ERROR( "oops, the something happened" ); - * else - * everything_okay(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the YY_FATAL_ERROR() call. - */ - #ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) \ - do \ - { \ -%- - (void) putc( '\n', stderr ); \ -%+ - cerr << msg << '\n'; \ -%* - exit( 1 ); \ - } \ - while ( 0 ) +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif /* Enter a start condition. This macro really ought to take a parameter, @@ -195,7 +170,22 @@ extern "C" { #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + /* Return all but the first 'n' matched characters back to the input stream. */ + #define yyless(n) \ do \ { \ @@ -302,6 +292,7 @@ static yy_state_type yy_get_previous_state YY_PROTO(( void )); static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); static int yy_get_next_buffer YY_PROTO(( void )); %* +static void yy_fatal_error YY_PROTO(( const char msg[] )); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -964,6 +955,22 @@ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file ) } +#ifdef YY_USE_PROTOS +void yy_fatal_error( const char msg[] ) +#else +void yy_fatal_error( msg ) +char msg[]; +#endif + { +%- + (void) putc( '\n', stderr ); +%+ + cerr << msg << '\n'; +%* + exit( 1 ); + } + + /* Redefine yyless() so it works in section 3 code. */ #undef yyless -- 2.40.0