diff options
-rw-r--r-- | Source/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Source/cmDependsFortran.cxx | 14 | ||||
-rw-r--r-- | Source/cmDependsFortranLexer.cxx (renamed from Source/cmDependsFortranLexer.c) | 174 | ||||
-rw-r--r-- | Source/cmDependsFortranLexer.h | 31 | ||||
-rw-r--r-- | Source/cmDependsFortranLexer.in.l | 32 | ||||
-rw-r--r-- | Source/cmDependsFortranParser.cxx (renamed from Source/cmDependsFortranParser.c) | 75 | ||||
-rw-r--r-- | Source/cmDependsFortranParser.h | 29 | ||||
-rw-r--r-- | Source/cmDependsFortranParser.y | 30 | ||||
-rw-r--r-- | Source/cmDependsFortranParserTokens.h | 2 |
9 files changed, 191 insertions, 200 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 7c99a7e..78169dc 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -14,8 +14,8 @@ SET(SRCS cmDependsC.h cmDependsFortran.cxx cmDependsFortran.h - cmDependsFortranLexer.c - cmDependsFortranParser.c + cmDependsFortranLexer.cxx + cmDependsFortranParser.cxx cmDependsFortranParser.h cmDependsJavaLexer.cxx cmDependsJavaParser.cxx diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 53cfaeb..065684a 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -18,7 +18,6 @@ #include "cmSystemTools.h" -#include "cmDependsFortranLexer.h" /* Interface to lexer object. */ #include "cmDependsFortranParser.h" /* Interface to parser object. */ #include <assert.h> @@ -26,15 +25,14 @@ //---------------------------------------------------------------------------- // Parser methods not included in generated interface. -extern "C" -{ - // Get the current buffer processed by the lexer. - YY_BUFFER_STATE cmDependsFortranLexer_GetCurrentBuffer(yyscan_t yyscanner); - // The parser entry point. - int cmDependsFortran_yyparse(yyscan_t); -} +// Get the current buffer processed by the lexer. +YY_BUFFER_STATE cmDependsFortranLexer_GetCurrentBuffer(yyscan_t yyscanner); +// The parser entry point. +int cmDependsFortran_yyparse(yyscan_t); + +//---------------------------------------------------------------------------- // Define parser object internal structure. struct cmDependsFortranFile { diff --git a/Source/cmDependsFortranLexer.c b/Source/cmDependsFortranLexer.cxx index 656b0a4..0932a6f 100644 --- a/Source/cmDependsFortranLexer.c +++ b/Source/cmDependsFortranLexer.cxx @@ -1,6 +1,6 @@ -#line 2 "cmDependsFortranLexer.c" +#line 2 "cmDependsFortranLexer.cxx" -#line 4 "cmDependsFortranLexer.c" +#line 4 "cmDependsFortranLexer.cxx" #define YY_INT_ALIGNED short int @@ -626,30 +626,22 @@ This file must be translated to C and modified to build everywhere. Run flex like this: - flex --prefix=cmDependsFortran_yy --header-file=cmDependsFortranLexer.h -ocmDependsFortranLexer.c cmDependsFortranLexer.in.l + flex --prefix=cmDependsFortran_yy --header-file=cmDependsFortranLexer.h -ocmDependsFortranLexer.cxx cmDependsFortranLexer.in.l -Modify cmDependsFortranLexer.c: +Modify cmDependsFortranLexer.cxx: - remove TABs - - add a statement "(void)yyscanner;" to the top of these methods: + - remove "yyscanner" argument from these methods: yy_fatal_error, cmDependsFortran_yyalloc, cmDependsFortran_yyrealloc, cmDependsFortran_yyfree - - remove all YY_BREAK lines occurring right after return statements Modify cmDependsFortranLexer.h: - remove TABs - remove the yy_init_globals function - - add these lines around all function declarations: - #ifdef __cplusplus - extern "C" - { - #endif - ... - #ifdef __cplusplus - } - #endif - remove the block that includes unistd.h + - remove #line directives (avoids bogus warning on old Sun) */ +#define cmDependsFortranLexer_cxx #include "cmDependsFortranParser.h" /* Interface to parser object. */ /* Disable some warnings. */ @@ -667,25 +659,29 @@ Modify cmDependsFortranLexer.h: /* Disable features we do not need. */ #define YY_NEVER_INTERACTIVE 1 -#define YY_NO_UNISTD_H 1 #define ECHO -/* Setup the proper cmDependsFortran_yylex declaration. */ -#define YY_EXTRA_TYPE cmDependsFortranParser* -#define YY_DECL int cmDependsFortran_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) - /* Replace the lexer input function. */ #undef YY_INPUT #define YY_INPUT(buf, result, 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 "cmDependsFortranParserTokens.h" /*--------------------------------------------------------------------------*/ -#line 689 "cmDependsFortranLexer.c" +#line 685 "cmDependsFortranLexer.cxx" #define INITIAL 0 #define free_fmt 1 @@ -907,10 +903,10 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 100 "cmDependsFortranLexer.in.l" +#line 96 "cmDependsFortranLexer.in.l" -#line 914 "cmDependsFortranLexer.c" +#line 910 "cmDependsFortranLexer.cxx" if ( yyg->yy_init ) { @@ -996,7 +992,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 102 "cmDependsFortranLexer.in.l" +#line 98 "cmDependsFortranLexer.in.l" { cmDependsFortranParser_StringStart(yyextra); BEGIN(str_dq); @@ -1004,48 +1000,50 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 107 "cmDependsFortranLexer.in.l" +#line 103 "cmDependsFortranLexer.in.l" { cmDependsFortranParser_StringStart(yyextra); BEGIN(str_sq); } YY_BREAK case 3: -#line 113 "cmDependsFortranLexer.in.l" +#line 109 "cmDependsFortranLexer.in.l" case 4: YY_RULE_SETUP -#line 113 "cmDependsFortranLexer.in.l" +#line 109 "cmDependsFortranLexer.in.l" { yylvalp->string = strdup(cmDependsFortranParser_StringEnd(yyextra)); return STRING; } + YY_BREAK case 5: /* rule 5 can match eol */ -#line 119 "cmDependsFortranLexer.in.l" +#line 115 "cmDependsFortranLexer.in.l" case 6: /* rule 6 can match eol */ YY_RULE_SETUP -#line 119 "cmDependsFortranLexer.in.l" +#line 115 "cmDependsFortranLexer.in.l" /* Ignore (continued strings, free fmt) */ YY_BREAK case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 121 "cmDependsFortranLexer.in.l" +#line 117 "cmDependsFortranLexer.in.l" /*Ignore (cont. strings, fixed fmt) */ YY_BREAK case 8: /* rule 8 can match eol */ YY_RULE_SETUP -#line 123 "cmDependsFortranLexer.in.l" +#line 119 "cmDependsFortranLexer.in.l" { unput ('\n'); BEGIN(INITIAL); return UNTERMINATED_STRING; } + YY_BREAK case 9: YY_RULE_SETUP -#line 129 "cmDependsFortranLexer.in.l" +#line 125 "cmDependsFortranLexer.in.l" { cmDependsFortranParser_StringAppend(yyextra, yytext[0]); } @@ -1053,55 +1051,62 @@ YY_RULE_SETUP case 10: /* rule 10 can match eol */ YY_RULE_SETUP -#line 133 "cmDependsFortranLexer.in.l" +#line 129 "cmDependsFortranLexer.in.l" { return EOSTMT; } /* Treat comments like */ + YY_BREAK case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 134 "cmDependsFortranLexer.in.l" +#line 130 "cmDependsFortranLexer.in.l" { return EOSTMT; } /* empty lines */ + YY_BREAK case 12: YY_RULE_SETUP -#line 136 "cmDependsFortranLexer.in.l" +#line 132 "cmDependsFortranLexer.in.l" { return CPP_INCLUDE; } + YY_BREAK case 13: YY_RULE_SETUP -#line 137 "cmDependsFortranLexer.in.l" +#line 133 "cmDependsFortranLexer.in.l" { return F90PPR_INCLUDE; } + YY_BREAK case 14: YY_RULE_SETUP -#line 138 "cmDependsFortranLexer.in.l" +#line 134 "cmDependsFortranLexer.in.l" { return COCO_INCLUDE; } + YY_BREAK case 15: YY_RULE_SETUP -#line 139 "cmDependsFortranLexer.in.l" +#line 135 "cmDependsFortranLexer.in.l" { return F_INCLUDE; } + YY_BREAK case 16: YY_RULE_SETUP -#line 140 "cmDependsFortranLexer.in.l" +#line 136 "cmDependsFortranLexer.in.l" { return USE; } + YY_BREAK case 17: YY_RULE_SETUP -#line 142 "cmDependsFortranLexer.in.l" +#line 138 "cmDependsFortranLexer.in.l" { cmDependsFortranParser_SetInInterface(yyextra, 0); } YY_BREAK case 18: YY_RULE_SETUP -#line 145 "cmDependsFortranLexer.in.l" +#line 141 "cmDependsFortranLexer.in.l" { cmDependsFortranParser_SetInInterface(yyextra, 1); } YY_BREAK case 19: YY_RULE_SETUP -#line 149 "cmDependsFortranLexer.in.l" +#line 145 "cmDependsFortranLexer.in.l" /* Ignore */ YY_BREAK case 20: YY_RULE_SETUP -#line 150 "cmDependsFortranLexer.in.l" +#line 146 "cmDependsFortranLexer.in.l" { if(!cmDependsFortranParser_GetInInterface(yyextra)) { @@ -1111,102 +1116,120 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -#line 157 "cmDependsFortranLexer.in.l" +#line 153 "cmDependsFortranLexer.in.l" { return CPP_DEFINE; } + YY_BREAK case 22: YY_RULE_SETUP -#line 158 "cmDependsFortranLexer.in.l" +#line 154 "cmDependsFortranLexer.in.l" { return F90PPR_DEFINE; } + YY_BREAK case 23: YY_RULE_SETUP -#line 160 "cmDependsFortranLexer.in.l" +#line 156 "cmDependsFortranLexer.in.l" { return CPP_UNDEF; } + YY_BREAK case 24: YY_RULE_SETUP -#line 161 "cmDependsFortranLexer.in.l" +#line 157 "cmDependsFortranLexer.in.l" { return F90PPR_UNDEF; } + YY_BREAK case 25: YY_RULE_SETUP -#line 163 "cmDependsFortranLexer.in.l" +#line 159 "cmDependsFortranLexer.in.l" { return CPP_IFDEF; } + YY_BREAK case 26: YY_RULE_SETUP -#line 164 "cmDependsFortranLexer.in.l" +#line 160 "cmDependsFortranLexer.in.l" { return CPP_IFNDEF; } + YY_BREAK case 27: YY_RULE_SETUP -#line 165 "cmDependsFortranLexer.in.l" +#line 161 "cmDependsFortranLexer.in.l" { return CPP_IF; } + YY_BREAK case 28: YY_RULE_SETUP -#line 166 "cmDependsFortranLexer.in.l" +#line 162 "cmDependsFortranLexer.in.l" { return CPP_ELIF; } + YY_BREAK case 29: YY_RULE_SETUP -#line 167 "cmDependsFortranLexer.in.l" +#line 163 "cmDependsFortranLexer.in.l" { return CPP_ELSE; } + YY_BREAK case 30: YY_RULE_SETUP -#line 168 "cmDependsFortranLexer.in.l" +#line 164 "cmDependsFortranLexer.in.l" { return CPP_ENDIF; } + YY_BREAK case 31: YY_RULE_SETUP -#line 170 "cmDependsFortranLexer.in.l" +#line 166 "cmDependsFortranLexer.in.l" { return F90PPR_IFDEF; } + YY_BREAK case 32: YY_RULE_SETUP -#line 171 "cmDependsFortranLexer.in.l" +#line 167 "cmDependsFortranLexer.in.l" { return F90PPR_IFNDEF; } + YY_BREAK case 33: YY_RULE_SETUP -#line 172 "cmDependsFortranLexer.in.l" +#line 168 "cmDependsFortranLexer.in.l" { return F90PPR_IF; } + YY_BREAK case 34: YY_RULE_SETUP -#line 173 "cmDependsFortranLexer.in.l" +#line 169 "cmDependsFortranLexer.in.l" { return F90PPR_ELIF; } + YY_BREAK case 35: YY_RULE_SETUP -#line 174 "cmDependsFortranLexer.in.l" +#line 170 "cmDependsFortranLexer.in.l" { return F90PPR_ELSE; } + YY_BREAK case 36: YY_RULE_SETUP -#line 175 "cmDependsFortranLexer.in.l" +#line 171 "cmDependsFortranLexer.in.l" { return F90PPR_ENDIF; } + YY_BREAK case 37: /* rule 37 can match eol */ -#line 178 "cmDependsFortranLexer.in.l" +#line 174 "cmDependsFortranLexer.in.l" case 38: /* rule 38 can match eol */ YY_RULE_SETUP -#line 178 "cmDependsFortranLexer.in.l" +#line 174 "cmDependsFortranLexer.in.l" /* Ignore */ YY_BREAK case 39: YY_RULE_SETUP -#line 181 "cmDependsFortranLexer.in.l" +#line 177 "cmDependsFortranLexer.in.l" { yylvalp->string = strdup(yytext); return WORD; } YY_BREAK case 40: /* rule 40 can match eol */ YY_RULE_SETUP -#line 183 "cmDependsFortranLexer.in.l" +#line 179 "cmDependsFortranLexer.in.l" { return EOSTMT; } + YY_BREAK case 41: YY_RULE_SETUP -#line 185 "cmDependsFortranLexer.in.l" +#line 181 "cmDependsFortranLexer.in.l" /* Ignore */ YY_BREAK case 42: YY_RULE_SETUP -#line 187 "cmDependsFortranLexer.in.l" +#line 183 "cmDependsFortranLexer.in.l" { return *yytext; } + YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(free_fmt): case YY_STATE_EOF(fixed_fmt): case YY_STATE_EOF(str_sq): case YY_STATE_EOF(str_dq): -#line 189 "cmDependsFortranLexer.in.l" +#line 185 "cmDependsFortranLexer.in.l" { if(!cmDependsFortranParser_FilePop(yyextra)) { @@ -1216,10 +1239,10 @@ case YY_STATE_EOF(str_dq): YY_BREAK case 43: YY_RULE_SETUP -#line 196 "cmDependsFortranLexer.in.l" +#line 192 "cmDependsFortranLexer.in.l" ECHO; YY_BREAK -#line 1250 "cmDependsFortranLexer.c" +#line 1246 "cmDependsFortranLexer.cxx" case YY_END_OF_BUFFER: { @@ -2019,9 +2042,8 @@ YY_BUFFER_STATE cmDependsFortran_yy_scan_bytes (yyconst char * bytes, int len #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +static void yy_fatal_error (yyconst char* msg , yyscan_t) { - (void)yyscanner; (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -2298,15 +2320,13 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) } #endif -void *cmDependsFortran_yyalloc (yy_size_t size , yyscan_t yyscanner) +void *cmDependsFortran_yyalloc (yy_size_t size , yyscan_t) { - (void)yyscanner; return (void *) malloc( size ); } -void *cmDependsFortran_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +void *cmDependsFortran_yyrealloc (void * ptr, yy_size_t size , yyscan_t) { - (void)yyscanner; /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -2317,9 +2337,8 @@ void *cmDependsFortran_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscan return (void *) realloc( (char *) ptr, size ); } -void cmDependsFortran_yyfree (void * ptr , yyscan_t yyscanner) +void cmDependsFortran_yyfree (void * ptr , yyscan_t) { - (void)yyscanner; free( (char *) ptr ); /* see cmDependsFortran_yyrealloc() for (char *) cast */ } @@ -2337,7 +2356,7 @@ void cmDependsFortran_yyfree (void * ptr , yyscan_t yyscanner) #undef YY_DECL_IS_OURS #undef YY_DECL #endif -#line 196 "cmDependsFortranLexer.in.l" +#line 192 "cmDependsFortranLexer.in.l" @@ -2348,4 +2367,3 @@ YY_BUFFER_STATE cmDependsFortranLexer_GetCurrentBuffer(yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return YY_CURRENT_BUFFER; } - diff --git a/Source/cmDependsFortranLexer.h b/Source/cmDependsFortranLexer.h index eadd193..94dff8f 100644 --- a/Source/cmDependsFortranLexer.h +++ b/Source/cmDependsFortranLexer.h @@ -2,10 +2,6 @@ #define cmDependsFortran_yyHEADER_H 1 #define cmDependsFortran_yyIN_HEADER 1 -#line 6 "cmDependsFortranLexer.h" - -#line 8 "cmDependsFortranLexer.h" - #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ @@ -120,14 +116,7 @@ typedef void* yyscan_t; #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) #define yy_flex_debug yyg->yy_flex_debug_r -#ifdef __cplusplus -extern "C" -{ -#endif int cmDependsFortran_yylex_init (yyscan_t* scanner); -#ifdef __cplusplus -} /* extern "C" */ -#endif #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE @@ -195,10 +184,6 @@ struct yy_buffer_state }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ -#ifdef __cplusplus -extern "C" -{ -#endif void cmDependsFortran_yyrestart (FILE *input_file ,yyscan_t yyscanner ); void cmDependsFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); YY_BUFFER_STATE cmDependsFortran_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); @@ -215,10 +200,6 @@ void *cmDependsFortran_yyalloc (yy_size_t ,yyscan_t yyscanner ); void *cmDependsFortran_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); void cmDependsFortran_yyfree (void * ,yyscan_t yyscanner ); -#ifdef __cplusplus -} /* extern "C" */ -#endif - /* Begin user sect3 */ #define cmDependsFortran_yywrap(n) 1 @@ -242,11 +223,6 @@ void cmDependsFortran_yyfree (void * ,yyscan_t yyscanner ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -#ifdef __cplusplus -extern "C" -{ -#endif - int cmDependsFortran_yylex_destroy (yyscan_t yyscanner ); int cmDependsFortran_yyget_debug (yyscan_t yyscanner ); @@ -273,10 +249,6 @@ int cmDependsFortran_yyget_lineno (yyscan_t yyscanner ); void cmDependsFortran_yyset_lineno (int line_number ,yyscan_t yyscanner ); -#ifdef __cplusplus -} /* extern "C" */ -#endif - /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -336,9 +308,6 @@ extern int cmDependsFortran_yylex (yyscan_t yyscanner); #undef YY_DECL_IS_OURS #undef YY_DECL #endif -#line 196 "cmDependsFortranLexer.in.l" - -#line 329 "cmDependsFortranLexer.h" #undef cmDependsFortran_yyIN_HEADER #endif /* cmDependsFortran_yyHEADER_H */ diff --git a/Source/cmDependsFortranLexer.in.l b/Source/cmDependsFortranLexer.in.l index dee871c..97d41d6 100644 --- a/Source/cmDependsFortranLexer.in.l +++ b/Source/cmDependsFortranLexer.in.l @@ -31,30 +31,22 @@ This file must be translated to C and modified to build everywhere. Run flex like this: - flex --prefix=cmDependsFortran_yy --header-file=cmDependsFortranLexer.h -ocmDependsFortranLexer.c cmDependsFortranLexer.in.l + flex --prefix=cmDependsFortran_yy --header-file=cmDependsFortranLexer.h -ocmDependsFortranLexer.cxx cmDependsFortranLexer.in.l -Modify cmDependsFortranLexer.c: +Modify cmDependsFortranLexer.cxx: - remove TABs - - add a statement "(void)yyscanner;" to the top of these methods: + - remove "yyscanner" argument from these methods: yy_fatal_error, yyalloc, yyrealloc, yyfree - - remove all YY_BREAK lines occurring right after return statements Modify cmDependsFortranLexer.h: - remove TABs - remove the yy_init_globals function - - add these lines around all function declarations: - #ifdef __cplusplus - extern "C" - { - #endif - ... - #ifdef __cplusplus - } - #endif - remove the block that includes unistd.h + - remove #line directives (avoids bogus warning on old Sun) */ +#define cmDependsFortranLexer_cxx #include "cmDependsFortranParser.h" /* Interface to parser object. */ /* Disable some warnings. */ @@ -72,18 +64,22 @@ Modify cmDependsFortranLexer.h: /* Disable features we do not need. */ #define YY_NEVER_INTERACTIVE 1 -#define YY_NO_UNISTD_H 1 #define ECHO -/* Setup the proper yylex declaration. */ -#define YY_EXTRA_TYPE cmDependsFortranParser* -#define YY_DECL int cmDependsFortran_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) - /* Replace the lexer input function. */ #undef YY_INPUT #define YY_INPUT(buf, result, 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 "cmDependsFortranParserTokens.h" diff --git a/Source/cmDependsFortranParser.c b/Source/cmDependsFortranParser.cxx index 84eedd1..1de6eee 100644 --- a/Source/cmDependsFortranParser.c +++ b/Source/cmDependsFortranParser.cxx @@ -157,30 +157,34 @@ This file must be translated to C and modified to build everywhere. Run bison like this: - bison --yacc --name-prefix=cmDependsFortran_yy --defines=cmDependsFortranParserTokens.h -ocmDependsFortranParser.c cmDependsFortranParser.y + bison --yacc --name-prefix=cmDependsFortran_yy --defines=cmDependsFortranParserTokens.h -ocmDependsFortranParser.cxx cmDependsFortranParser.y -Modify cmDependsFortranParser.c: +Modify cmDependsFortranParser.cxx: - remove TABs */ +/*-------------------------------------------------------------------------*/ +#define cmDependsFortranParser_cxx +#include "cmDependsFortranParser.h" /* Interface to parser object. */ +#include "cmDependsFortranParserTokens.h" /* Need YYSTYPE for YY_DECL. */ + /* Configure the parser to use a lexer object. */ #define YYPARSE_PARAM yyscanner #define YYLEX_PARAM yyscanner -#define YY_DECL int cmDependsFortran_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) #define YYERROR_VERBOSE 1 #define cmDependsFortran_yyerror(x) \ cmDependsFortranError(yyscanner, x) -#include "cmDependsFortranLexer.h" /* Interface to lexer object. */ -#include "cmDependsFortranParser.h" /* Interface to parser object. */ -#include "cmDependsFortranParserTokens.h" /* Need YYSTYPE for YY_DECL. */ - /* Forward declare the lexer entry point. */ YY_DECL; -/* Internal utility functions. */ -static void cmDependsFortranError(yyscan_t yyscanner, const char* message); +/* Helper function to forward error callback. */ +static void cmDependsFortranError(yyscan_t yyscanner, const char* message) +{ + cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); + cmDependsFortranParser_Error(parser, message); +} /* Disable some warnings in the generated code. */ #ifdef __BORLANDC__ @@ -205,12 +209,12 @@ static void cmDependsFortranError(yyscan_t yyscanner, const char* message); #endif #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 71 "cmDependsFortranParser.y" +#line 75 "cmDependsFortranParser.y" typedef union YYSTYPE { char* string; } YYSTYPE; /* Line 191 of yacc.c. */ -#line 214 "cmDependsFortranParser.c" +#line 218 "cmDependsFortranParser.cxx" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 @@ -222,7 +226,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c. */ -#line 226 "cmDependsFortranParser.c" +#line 230 "cmDependsFortranParser.cxx" #if ! defined (yyoverflow) || YYERROR_VERBOSE @@ -412,11 +416,11 @@ static const yysigned_char yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned char yyrline[] = { - 0, 85, 85, 85, 88, 94, 100, 101, 107, 113, - 119, 125, 131, 136, 141, 146, 151, 154, 154, 155, - 155, 155, 155, 156, 156, 157, 157, 158, 158, 159, - 159, 160, 160, 161, 161, 162, 162, 163, 163, 164, - 164, 167, 168, 169 + 0, 93, 93, 93, 96, 102, 108, 109, 115, 121, + 127, 133, 139, 144, 149, 154, 159, 162, 162, 163, + 163, 163, 163, 164, 164, 165, 165, 166, 166, 167, + 167, 168, 168, 169, 169, 170, 170, 171, 171, 172, + 172, 175, 176, 177 }; #endif @@ -1161,7 +1165,7 @@ yyreduce: switch (yyn) { case 4: -#line 89 "cmDependsFortranParser.y" +#line 97 "cmDependsFortranParser.y" { cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); cmDependsFortranParser_RuleUse(parser, yyvsp[-2].string); @@ -1170,7 +1174,7 @@ yyreduce: break; case 5: -#line 95 "cmDependsFortranParser.y" +#line 103 "cmDependsFortranParser.y" { cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); cmDependsFortranParser_RuleInclude(parser, yyvsp[-2].string); @@ -1179,7 +1183,7 @@ yyreduce: break; case 7: -#line 102 "cmDependsFortranParser.y" +#line 110 "cmDependsFortranParser.y" { cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); cmDependsFortranParser_RuleModule(parser, yyvsp[-1].string); @@ -1188,7 +1192,7 @@ yyreduce: break; case 8: -#line 108 "cmDependsFortranParser.y" +#line 116 "cmDependsFortranParser.y" { cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); cmDependsFortranParser_RuleDefine(parser, yyvsp[-2].string); @@ -1197,7 +1201,7 @@ yyreduce: break; case 9: -#line 114 "cmDependsFortranParser.y" +#line 122 "cmDependsFortranParser.y" { cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); cmDependsFortranParser_RuleUndef(parser, yyvsp[-2].string); @@ -1206,7 +1210,7 @@ yyreduce: break; case 10: -#line 120 "cmDependsFortranParser.y" +#line 128 "cmDependsFortranParser.y" { cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); cmDependsFortranParser_RuleIfdef(parser, yyvsp[-2].string); @@ -1215,7 +1219,7 @@ yyreduce: break; case 11: -#line 126 "cmDependsFortranParser.y" +#line 134 "cmDependsFortranParser.y" { cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); cmDependsFortranParser_RuleIfndef(parser, yyvsp[-2].string); @@ -1224,7 +1228,7 @@ yyreduce: break; case 12: -#line 132 "cmDependsFortranParser.y" +#line 140 "cmDependsFortranParser.y" { cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); cmDependsFortranParser_RuleIf(parser); @@ -1232,7 +1236,7 @@ yyreduce: break; case 13: -#line 137 "cmDependsFortranParser.y" +#line 145 "cmDependsFortranParser.y" { cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); cmDependsFortranParser_RuleElif(parser); @@ -1240,7 +1244,7 @@ yyreduce: break; case 14: -#line 142 "cmDependsFortranParser.y" +#line 150 "cmDependsFortranParser.y" { cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); cmDependsFortranParser_RuleElse(parser); @@ -1248,7 +1252,7 @@ yyreduce: break; case 15: -#line 147 "cmDependsFortranParser.y" +#line 155 "cmDependsFortranParser.y" { cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); cmDependsFortranParser_RuleEndif(parser); @@ -1256,12 +1260,12 @@ yyreduce: break; case 41: -#line 167 "cmDependsFortranParser.y" +#line 175 "cmDependsFortranParser.y" { free (yyvsp[0].string); } break; case 42: -#line 168 "cmDependsFortranParser.y" +#line 176 "cmDependsFortranParser.y" { free (yyvsp[0].string); } break; @@ -1269,7 +1273,7 @@ yyreduce: } /* Line 1010 of yacc.c. */ -#line 1273 "cmDependsFortranParser.c" +#line 1277 "cmDependsFortranParser.cxx" yyvsp -= yylen; yyssp -= yylen; @@ -1494,12 +1498,7 @@ yyreturn: } -#line 172 "cmDependsFortranParser.y" +#line 180 "cmDependsFortranParser.y" +/* End of grammar */ -/*--------------------------------------------------------------------------*/ -void cmDependsFortranError(yyscan_t yyscanner, const char* message) -{ - cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); - cmDependsFortranParser_Error(parser, message); -} diff --git a/Source/cmDependsFortranParser.h b/Source/cmDependsFortranParser.h index 44cb1d5..468682f 100644 --- a/Source/cmDependsFortranParser.h +++ b/Source/cmDependsFortranParser.h @@ -17,14 +17,11 @@ #ifndef cmDependsFortranParser_h #define cmDependsFortranParser_h +#include <stddef.h> /* size_t */ + /* Forward declare parser object type. */ typedef struct cmDependsFortranParser_s cmDependsFortranParser; -#ifdef __cplusplus -extern "C" -{ -#endif - /* Functions to enter/exit #include'd files in order. */ int cmDependsFortranParser_FilePush(cmDependsFortranParser* parser, const char* fname); @@ -63,8 +60,26 @@ void cmDependsFortranParser_RuleElif(cmDependsFortranParser* parser); void cmDependsFortranParser_RuleElse(cmDependsFortranParser* parser); void cmDependsFortranParser_RuleEndif(cmDependsFortranParser* parser); -#ifdef __cplusplus -} /* extern "C" */ +/* Define the parser stack element type. */ +typedef union cmDependsFortran_yystype_u cmDependsFortran_yystype; +union cmDependsFortran_yystype_u +{ + char* string; +}; + +/* Setup the proper yylex interface. */ +#define YY_EXTRA_TYPE cmDependsFortranParser* +#define YY_DECL int cmDependsFortran_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) +#define YYSTYPE cmDependsFortran_yystype +#define YYSTYPE_IS_DECLARED 1 +#if !defined(cmDependsFortranLexer_cxx) +# include "cmDependsFortranLexer.h" +#endif +#if !defined(cmDependsFortranLexer_cxx) && !defined(cmDependsFortranParser_cxx) +# undef YY_EXTRA_TYPE +# undef YY_DECL +# undef YYSTYPE +# undef YYSTYPE_IS_DECLARED #endif #endif diff --git a/Source/cmDependsFortranParser.y b/Source/cmDependsFortranParser.y index 190a33a..4ba4117 100644 --- a/Source/cmDependsFortranParser.y +++ b/Source/cmDependsFortranParser.y @@ -31,31 +31,34 @@ This file must be translated to C and modified to build everywhere. Run bison like this: - bison --yacc --name-prefix=cmDependsFortran_yy --defines=cmDependsFortranParserTokens.h -ocmDependsFortranParser.c cmDependsFortranParser.y + bison --yacc --name-prefix=cmDependsFortran_yy --defines=cmDependsFortranParserTokens.h -ocmDependsFortranParser.cxx cmDependsFortranParser.y -Modify cmDependsFortranParser.c: +Modify cmDependsFortranParser.cxx: - remove TABs */ +/*-------------------------------------------------------------------------*/ +#define cmDependsFortranParser_cxx +#include "cmDependsFortranParser.h" /* Interface to parser object. */ +#include "cmDependsFortranParserTokens.h" /* Need YYSTYPE for YY_DECL. */ + /* Configure the parser to use a lexer object. */ #define YYPARSE_PARAM yyscanner #define YYLEX_PARAM yyscanner -#define YY_DECL int cmDependsFortran_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner) #define YYERROR_VERBOSE 1 #define cmDependsFortran_yyerror(x) \ cmDependsFortranError(yyscanner, x) -/*-------------------------------------------------------------------------*/ -#include "cmDependsFortranLexer.h" /* Interface to lexer object. */ -#include "cmDependsFortranParser.h" /* Interface to parser object. */ -#include "cmDependsFortranParserTokens.h" /* Need YYSTYPE for YY_DECL. */ - /* Forward declare the lexer entry point. */ YY_DECL; -/* Internal utility functions. */ -static void cmDependsFortranError(yyscan_t yyscanner, const char* message); +/* Helper function to forward error callback. */ +static void cmDependsFortranError(yyscan_t yyscanner, const char* message) +{ + cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); + cmDependsFortranParser_Error(parser, message); +} /* Disable some warnings in the generated code. */ #ifdef __BORLANDC__ @@ -176,10 +179,3 @@ misc_code: %% /* End of grammar */ - -/*--------------------------------------------------------------------------*/ -void cmDependsFortranError(yyscan_t yyscanner, const char* message) -{ - cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner); - cmDependsFortranParser_Error(parser, message); -} diff --git a/Source/cmDependsFortranParserTokens.h b/Source/cmDependsFortranParserTokens.h index aee7266..dec369e 100644 --- a/Source/cmDependsFortranParserTokens.h +++ b/Source/cmDependsFortranParserTokens.h @@ -90,7 +90,7 @@ #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 71 "cmDependsFortranParser.y" +#line 75 "cmDependsFortranParser.y" typedef union YYSTYPE { char* string; } YYSTYPE; |