COMP: Moved duplicate flex-generated lexer warning suppression and cross-platform support code to a single cmStandardLexer.h included by all lexer sources. Added fix for macro redefinitions on Borland 5.8 compiler.

This commit is contained in:
Brad King 2006-08-08 14:00:28 -04:00
parent 8f1aaf28c1
commit a3836e09a2
11 changed files with 96 additions and 309 deletions

View File

@ -477,31 +477,10 @@ Modify cmCommandArgumentLexer.h:
*/ */
#include "cmStandardLexer.h"
#include "cmCommandArgumentParserHelper.h" #include "cmCommandArgumentParserHelper.h"
/* Disable some warnings. */
#if defined(_MSC_VER)
# pragma warning ( disable : 4127 )
# pragma warning ( disable : 4131 )
# pragma warning ( disable : 4244 )
# pragma warning ( disable : 4251 )
# pragma warning ( disable : 4267 )
# pragma warning ( disable : 4305 )
# pragma warning ( disable : 4309 )
# pragma warning ( disable : 4706 )
# pragma warning ( disable : 4786 )
#endif
#if defined(__BORLANDC__)
# pragma warn -8008 /* condition always returns true */
# pragma warn -8066 /* unreachable code */
#endif
/* Disable features we do not need. */
#define YY_NEVER_INTERACTIVE 1
#undef ECHO /* SGI termios defines this differently. */
#define ECHO
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
@ -510,16 +489,6 @@ Modify cmCommandArgumentLexer.h:
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmCommandArgumentParserTokens.h" #include "cmCommandArgumentParserTokens.h"
#if defined( _WIN32 ) && !defined( __CYGWIN__ )
/* Handle Windows properly */
# include <io.h>
# if defined( _MSC_VER )
# define isatty _isatty
# endif
# define YY_NO_UNISTD_H 1
#endif
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/

View File

@ -26,7 +26,7 @@ Run flex like this:
Modify cmCommandArgumentLexer.cxx: Modify cmCommandArgumentLexer.cxx:
- remove TABs - remove TABs
- remove "yyscanner" argument from these methods: - remove "yyscanner" argument from these methods:
yy_fatal_error, yyalloc, yyrealloc, yyfree yy_fatal_error, cmCommandArgument_yyalloc, cmCommandArgument_yyrealloc, cmCommandArgument_yyfree
- remove all YY_BREAK lines occurring right after return statements - remove all YY_BREAK lines occurring right after return statements
- change while ( 1 ) to for(;;) - change while ( 1 ) to for(;;)
@ -38,31 +38,10 @@ Modify cmCommandArgumentLexer.h:
*/ */
#include "cmStandardLexer.h"
#include "cmCommandArgumentParserHelper.h" #include "cmCommandArgumentParserHelper.h"
/* Disable some warnings. */
#if defined(_MSC_VER)
# pragma warning ( disable : 4127 )
# pragma warning ( disable : 4131 )
# pragma warning ( disable : 4244 )
# pragma warning ( disable : 4251 )
# pragma warning ( disable : 4267 )
# pragma warning ( disable : 4305 )
# pragma warning ( disable : 4309 )
# pragma warning ( disable : 4706 )
# pragma warning ( disable : 4786 )
#endif
#if defined(__BORLANDC__)
# pragma warn -8008 /* condition always returns true */
# pragma warn -8066 /* unreachable code */
#endif
/* Disable features we do not need. */
#define YY_NEVER_INTERACTIVE 1
#undef ECHO /* SGI termios defines this differently. */
#define ECHO
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
@ -71,16 +50,6 @@ Modify cmCommandArgumentLexer.h:
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmCommandArgumentParserTokens.h" #include "cmCommandArgumentParserTokens.h"
#if defined( _WIN32 ) && !defined( __CYGWIN__ )
/* Handle Windows properly */
# include <io.h>
# if defined( _MSC_VER )
# define isatty _isatty
# endif
# define YY_NO_UNISTD_H 1
#endif
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
%} %}

View File

@ -640,45 +640,16 @@ Modify cmDependsFortranLexer.h:
*/ */
#include "cmStandardLexer.h"
#define cmDependsFortranLexer_cxx #define cmDependsFortranLexer_cxx
#include "cmDependsFortranParser.h" /* Interface to parser object. */ #include "cmDependsFortranParser.h" /* Interface to parser object. */
/* Disable some warnings. */
#if defined(_MSC_VER)
# pragma warning ( disable : 4127 )
# pragma warning ( disable : 4131 )
# pragma warning ( disable : 4244 )
# pragma warning ( disable : 4251 )
# pragma warning ( disable : 4267 )
# pragma warning ( disable : 4305 )
# pragma warning ( disable : 4309 )
# pragma warning ( disable : 4706 )
# pragma warning ( disable : 4786 )
#endif
#if defined(__BORLANDC__)
# pragma warn -8008 /* condition always returns true */
# pragma warn -8066 /* unreachable code */
#endif
/* Disable features we do not need. */
#define YY_NEVER_INTERACTIVE 1
#define ECHO
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = cmDependsFortranParser_Input(yyextra, buf, max_size); } { result = cmDependsFortranParser_Input(yyextra, buf, max_size); }
/* Provide isatty on Windows. */
#if defined( _WIN32 ) && !defined( __CYGWIN__ )
# include <io.h>
# if defined( _MSC_VER )
# define isatty _isatty
# endif
# define YY_NO_UNISTD_H 1
#endif
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmDependsFortranParserTokens.h" #include "cmDependsFortranParserTokens.h"

View File

@ -36,7 +36,7 @@ Run flex like this:
Modify cmDependsFortranLexer.cxx: Modify cmDependsFortranLexer.cxx:
- remove TABs - remove TABs
- remove "yyscanner" argument from these methods: - remove "yyscanner" argument from these methods:
yy_fatal_error, yyalloc, yyrealloc, yyfree yy_fatal_error, cmDependsFortran_yyalloc, cmDependsFortran_yyrealloc, cmDependsFortran_yyfree
- remove all YY_BREAK lines occurring right after return statements - remove all YY_BREAK lines occurring right after return statements
- change while ( 1 ) to for(;;) - change while ( 1 ) to for(;;)
@ -48,45 +48,16 @@ Modify cmDependsFortranLexer.h:
*/ */
#include "cmStandardLexer.h"
#define cmDependsFortranLexer_cxx #define cmDependsFortranLexer_cxx
#include "cmDependsFortranParser.h" /* Interface to parser object. */ #include "cmDependsFortranParser.h" /* Interface to parser object. */
/* Disable some warnings. */
#if defined(_MSC_VER)
# pragma warning ( disable : 4127 )
# pragma warning ( disable : 4131 )
# pragma warning ( disable : 4244 )
# pragma warning ( disable : 4251 )
# pragma warning ( disable : 4267 )
# pragma warning ( disable : 4305 )
# pragma warning ( disable : 4309 )
# pragma warning ( disable : 4706 )
# pragma warning ( disable : 4786 )
#endif
#if defined(__BORLANDC__)
# pragma warn -8008 /* condition always returns true */
# pragma warn -8066 /* unreachable code */
#endif
/* Disable features we do not need. */
#define YY_NEVER_INTERACTIVE 1
#define ECHO
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = cmDependsFortranParser_Input(yyextra, buf, max_size); } { result = cmDependsFortranParser_Input(yyextra, buf, max_size); }
/* Provide isatty on Windows. */
#if defined( _WIN32 ) && !defined( __CYGWIN__ )
# include <io.h>
# if defined( _MSC_VER )
# define isatty _isatty
# endif
# define YY_NO_UNISTD_H 1
#endif
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmDependsFortranParserTokens.h" #include "cmDependsFortranParserTokens.h"

View File

@ -671,34 +671,14 @@ Modify cmDependsJavaLexer.h:
- remove TABs - remove TABs
- remove the yy_init_globals function - remove the yy_init_globals function
- remove the block that includes unistd.h - remove the block that includes unistd.h
- remove #line directives (avoids bogus warning on old Sun)
*/ */
#include "cmStandardLexer.h"
#include "cmDependsJavaParserHelper.h" #include "cmDependsJavaParserHelper.h"
/* Disable some warnings. */
#if defined(_MSC_VER)
# pragma warning ( disable : 4127 )
# pragma warning ( disable : 4131 )
# pragma warning ( disable : 4244 )
# pragma warning ( disable : 4251 )
# pragma warning ( disable : 4267 )
# pragma warning ( disable : 4305 )
# pragma warning ( disable : 4309 )
# pragma warning ( disable : 4706 )
# pragma warning ( disable : 4786 )
#endif
#if defined(__BORLANDC__)
# pragma warn -8008 /* condition always returns true */
# pragma warn -8066 /* unreachable code */
#endif
/* Disable features we do not need. */
#define YY_NEVER_INTERACTIVE 1
#undef ECHO /* SGI termios defines this differently. */
#define ECHO
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
@ -707,16 +687,6 @@ Modify cmDependsJavaLexer.h:
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmDependsJavaParserTokens.h" #include "cmDependsJavaParserTokens.h"
#if defined( _WIN32 ) && !defined( __CYGWIN__ )
/* Handle Windows properly */
# include <io.h>
# if defined( _MSC_VER )
# define isatty _isatty
# endif
# define YY_NO_UNISTD_H 1
#endif
#define KEYWORD yylvalp->str = 0 #define KEYWORD yylvalp->str = 0
#define SYMBOL yylvalp->str = 0 #define SYMBOL yylvalp->str = 0
#define PRIMITIVE yylvalp->str = 0 #define PRIMITIVE yylvalp->str = 0

View File

@ -23,10 +23,10 @@ Run flex like this:
flex --prefix=cmDependsJava_yy --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l flex --prefix=cmDependsJava_yy --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l
Modify cmDependsJavaLexer.cxx: Modify cmDependsJavaLexer.c:
- remove TABs - remove TABs
- remove "yyscanner" argument from these methods: - remove "yyscanner" argument from these methods:
yy_fatal_error, yyalloc, yyrealloc, yyfree yy_fatal_error, cmDependsJava_yyalloc, cmDependsJava_yyrealloc, cmDependsJava_yyfree
- remove all YY_BREAK lines occurring right after return statements - remove all YY_BREAK lines occurring right after return statements
- change while ( 1 ) to for(;;) - change while ( 1 ) to for(;;)
@ -38,31 +38,10 @@ Modify cmDependsJavaLexer.h:
*/ */
#include "cmStandardLexer.h"
#include "cmDependsJavaParserHelper.h" #include "cmDependsJavaParserHelper.h"
/* Disable some warnings. */
#if defined(_MSC_VER)
# pragma warning ( disable : 4127 )
# pragma warning ( disable : 4131 )
# pragma warning ( disable : 4244 )
# pragma warning ( disable : 4251 )
# pragma warning ( disable : 4267 )
# pragma warning ( disable : 4305 )
# pragma warning ( disable : 4309 )
# pragma warning ( disable : 4706 )
# pragma warning ( disable : 4786 )
#endif
#if defined(__BORLANDC__)
# pragma warn -8008 /* condition always returns true */
# pragma warn -8066 /* unreachable code */
#endif
/* Disable features we do not need. */
#define YY_NEVER_INTERACTIVE 1
#undef ECHO /* SGI termios defines this differently. */
#define ECHO
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
@ -71,16 +50,6 @@ Modify cmDependsJavaLexer.h:
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmDependsJavaParserTokens.h" #include "cmDependsJavaParserTokens.h"
#if defined( _WIN32 ) && !defined( __CYGWIN__ )
/* Handle Windows properly */
# include <io.h>
# if defined( _MSC_VER )
# define isatty _isatty
# endif
# define YY_NO_UNISTD_H 1
#endif
#define KEYWORD yylvalp->str = 0 #define KEYWORD yylvalp->str = 0
#define SYMBOL yylvalp->str = 0 #define SYMBOL yylvalp->str = 0
#define PRIMITIVE yylvalp->str = 0 #define PRIMITIVE yylvalp->str = 0

View File

@ -458,8 +458,7 @@ This file must be translated to C and modified to build everywhere.
Run flex like this: Run flex like this:
flex --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx flex --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l
cmExprLexer.in.l
Modify cmExprLexer.cxx: Modify cmExprLexer.cxx:
- remove TABs - remove TABs
@ -476,31 +475,10 @@ Modify cmExprLexer.h:
*/ */
#include "cmStandardLexer.h"
#include "cmExprParserHelper.h" #include "cmExprParserHelper.h"
/* Disable some warnings. */
#if defined(_MSC_VER)
# pragma warning ( disable : 4127 )
# pragma warning ( disable : 4131 )
# pragma warning ( disable : 4244 )
# pragma warning ( disable : 4251 )
# pragma warning ( disable : 4267 )
# pragma warning ( disable : 4305 )
# pragma warning ( disable : 4309 )
# pragma warning ( disable : 4706 )
# pragma warning ( disable : 4786 )
#endif
#if defined(__BORLANDC__)
# pragma warn -8008 /* condition always returns true */
# pragma warn -8066 /* unreachable code */
#endif
/* Disable features we do not need. */
#define YY_NEVER_INTERACTIVE 1
#undef ECHO /* SGI termios defines this differently. */
#define ECHO
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
@ -509,16 +487,6 @@ Modify cmExprLexer.h:
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmExprParserTokens.h" #include "cmExprParserTokens.h"
#if defined( _WIN32 ) && !defined( __CYGWIN__ )
/* Handle Windows properly */
# include <io.h>
# if defined( _MSC_VER )
# define isatty _isatty
# endif
# define YY_NO_UNISTD_H 1
#endif
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
#line 518 "/home/andy/vtk/CMake-bin/Source/cmExprLexer.cxx" #line 518 "/home/andy/vtk/CMake-bin/Source/cmExprLexer.cxx"

View File

@ -26,7 +26,7 @@ Run flex like this:
Modify cmExprLexer.cxx: Modify cmExprLexer.cxx:
- remove TABs - remove TABs
- remove "yyscanner" argument from these methods: - remove "yyscanner" argument from these methods:
yy_fatal_error, yyalloc, yyrealloc, yyfree yy_fatal_error, cmExpr_yyalloc, cmExpr_yyrealloc, cmExpr_yyfree
- remove all YY_BREAK lines occurring right after return statements - remove all YY_BREAK lines occurring right after return statements
- change while ( 1 ) to for(;;) - change while ( 1 ) to for(;;)
@ -38,31 +38,10 @@ Modify cmExprLexer.h:
*/ */
#include "cmStandardLexer.h"
#include "cmExprParserHelper.h" #include "cmExprParserHelper.h"
/* Disable some warnings. */
#if defined(_MSC_VER)
# pragma warning ( disable : 4127 )
# pragma warning ( disable : 4131 )
# pragma warning ( disable : 4244 )
# pragma warning ( disable : 4251 )
# pragma warning ( disable : 4267 )
# pragma warning ( disable : 4305 )
# pragma warning ( disable : 4309 )
# pragma warning ( disable : 4706 )
# pragma warning ( disable : 4786 )
#endif
#if defined(__BORLANDC__)
# pragma warn -8008 /* condition always returns true */
# pragma warn -8066 /* unreachable code */
#endif
/* Disable features we do not need. */
#define YY_NEVER_INTERACTIVE 1
#undef ECHO /* SGI termios defines this differently. */
#define ECHO
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
@ -71,16 +50,6 @@ Modify cmExprLexer.h:
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmExprParserTokens.h" #include "cmExprParserTokens.h"
#if defined( _WIN32 ) && !defined( __CYGWIN__ )
/* Handle Windows properly */
# include <io.h>
# if defined( _MSC_VER )
# define isatty _isatty
# endif
# define YY_NO_UNISTD_H 1
#endif
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
%} %}

View File

@ -506,35 +506,17 @@ Modify cmListFileLexer.c:
*/ */
#include "cmStandardLexer.h"
/* Disable features we do not need. */ /* Disable features we do not need. */
#define YY_NEVER_INTERACTIVE 1
#define YY_NO_INPUT 1 #define YY_NO_INPUT 1
#define YY_NO_UNPUT 1 #define YY_NO_UNPUT 1
#define YY_NO_UNISTD_H 1 #define YY_NO_UNISTD_H 1
#define ECHO
/* Setup the proper cmListFileLexer_yylex declaration. */ /* Setup the proper cmListFileLexer_yylex declaration. */
#define YY_EXTRA_TYPE cmListFileLexer* #define YY_EXTRA_TYPE cmListFileLexer*
#define YY_DECL int cmListFileLexer_yylex (yyscan_t yyscanner, cmListFileLexer* lexer) #define YY_DECL int cmListFileLexer_yylex (yyscan_t yyscanner, cmListFileLexer* lexer)
/* Disable some warnings. */
#if defined(_MSC_VER)
# pragma warning ( disable : 4127 )
# pragma warning ( disable : 4131 )
# pragma warning ( disable : 4244 )
# pragma warning ( disable : 4251 )
# pragma warning ( disable : 4267 )
# pragma warning ( disable : 4305 )
# pragma warning ( disable : 4309 )
# pragma warning ( disable : 4706 )
# pragma warning ( disable : 4786 )
#endif
#if defined(__BORLANDC__)
# pragma warn -8008 /* condition always returns true */
# pragma warn -8066 /* unreachable code */
#endif
#include "cmListFileLexer.h" #include "cmListFileLexer.h"
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/

View File

@ -27,40 +27,22 @@ Modify cmListFileLexer.c:
- remove TABs - remove TABs
- remove the yyunput function - remove the yyunput function
- add a statement "(void)yyscanner;" to the top of these methods: - add a statement "(void)yyscanner;" to the top of these methods:
yy_fatal_error, yyalloc, yyrealloc, yyfree yy_fatal_error, cmListFileLexer_yyalloc, cmListFileLexer_yyrealloc, cmListFileLexer_yyfree
- remove all YY_BREAK lines occurring right after return statements - remove all YY_BREAK lines occurring right after return statements
*/ */
#include "cmStandardLexer.h"
/* Disable features we do not need. */ /* Disable features we do not need. */
#define YY_NEVER_INTERACTIVE 1
#define YY_NO_INPUT 1 #define YY_NO_INPUT 1
#define YY_NO_UNPUT 1 #define YY_NO_UNPUT 1
#define YY_NO_UNISTD_H 1 #define YY_NO_UNISTD_H 1
#define ECHO
/* Setup the proper yylex declaration. */ /* Setup the proper cmListFileLexer_yylex declaration. */
#define YY_EXTRA_TYPE cmListFileLexer* #define YY_EXTRA_TYPE cmListFileLexer*
#define YY_DECL int cmListFileLexer_yylex (yyscan_t yyscanner, cmListFileLexer* lexer) #define YY_DECL int cmListFileLexer_yylex (yyscan_t yyscanner, cmListFileLexer* lexer)
/* Disable some warnings. */
#if defined(_MSC_VER)
# pragma warning ( disable : 4127 )
# pragma warning ( disable : 4131 )
# pragma warning ( disable : 4244 )
# pragma warning ( disable : 4251 )
# pragma warning ( disable : 4267 )
# pragma warning ( disable : 4305 )
# pragma warning ( disable : 4309 )
# pragma warning ( disable : 4706 )
# pragma warning ( disable : 4786 )
#endif
#if defined(__BORLANDC__)
# pragma warn -8008 /* condition always returns true */
# pragma warn -8066 /* unreachable code */
#endif
#include "cmListFileLexer.h" #include "cmListFileLexer.h"
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/

67
Source/cmStandardLexer.h Normal file
View File

@ -0,0 +1,67 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmStandardLexer_h
#define cmStandardLexer_h
/* Disable some warnings. */
#if defined(_MSC_VER)
# pragma warning ( disable : 4127 )
# pragma warning ( disable : 4131 )
# pragma warning ( disable : 4244 )
# pragma warning ( disable : 4251 )
# pragma warning ( disable : 4267 )
# pragma warning ( disable : 4305 )
# pragma warning ( disable : 4309 )
# pragma warning ( disable : 4706 )
# pragma warning ( disable : 4786 )
#endif
#if defined(__BORLANDC__)
# pragma warn -8008 /* condition always returns true */
# pragma warn -8066 /* unreachable code */
/* Borland system header defines these macros without first undef-ing them. */
# if __BORLANDC__ >= 0x580
# undef INT8_MIN
# undef INT16_MIN
# undef INT32_MIN
# undef INT8_MAX
# undef INT16_MAX
# undef INT32_MAX
# undef UINT8_MAX
# undef UINT16_MAX
# undef UINT32_MAX
# include <stdint.h>
# endif
#endif
/* Define isatty on windows. */
#if defined(_WIN32) && !defined(__CYGWIN__)
# include <io.h>
# if defined( _MSC_VER )
# define isatty _isatty
# endif
# define YY_NO_UNISTD_H 1
#endif
/* Disable features we do not need. */
#define YY_NEVER_INTERACTIVE 1
/* Avoid display of input matches to standard output. */
#undef ECHO /* SGI termios defines this differently. */
#define ECHO
#endif