]> granicus.if.org Git - flex/commitdiff
Added yy_fatal_error function.
authorVern Paxson <vern@ee.lbl.gov>
Mon, 4 Oct 1993 10:17:40 +0000 (10:17 +0000)
committerVern Paxson <vern@ee.lbl.gov>
Mon, 4 Oct 1993 10:17:40 +0000 (10:17 +0000)
flex.skl

index afb785747caf07b0d68fa50ab44e30ca42eb389b..1590b6d2849fe075f3e7026554de17447de1094b 100644 (file)
--- a/flex.skl
+++ b/flex.skl
 #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