2 /*============================================================================
3 CMake - Cross Platform Makefile Generator
4 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
6 Distributed under the OSI-approved BSD License (the "License");
7 see accompanying file Copyright.txt for details.
9 This software is distributed WITHOUT ANY WARRANTY; without even the
10 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 See the License for more information.
12 ============================================================================*/
13 /*-------------------------------------------------------------------------
14 Portions of this source have been derived from makedepf90 version 2.8.8,
16 Copyright (C) 2000--2006 Erik Edelmann <erik.edelmann@iki.fi>
18 The code was originally distributed under the GPL but permission
19 from the copyright holder has been obtained to distribute this
20 derived work under the CMake license.
21 -------------------------------------------------------------------------*/
25 This file must be translated to C and modified to build everywhere.
29 flex -i --prefix=cmDependsFortran_yy --header-file=cmDependsFortranLexer.h -ocmDependsFortranLexer.cxx cmDependsFortranLexer.in.l
31 Modify cmDependsFortranLexer.cxx:
33 - remove "yyscanner" argument from these methods:
34 yy_fatal_error, cmDependsFortran_yyalloc, cmDependsFortran_yyrealloc, cmDependsFortran_yyfree
35 - remove "yyscanner = NULL" from end of cmDependsFortran_yylex_destroy
36 - remove all YY_BREAK lines occurring right after return statements
37 - change while ( 1 ) to for(;;)
39 Modify cmDependsFortranLexer.h:
41 - remove the yy_init_globals function
42 - remove the block that includes unistd.h
43 - remove #line directives (avoids bogus warning on old Sun)
47 #include "cmStandardLexer.h"
49 #define cmDependsFortranLexer_cxx
50 #include "cmDependsFortranParser.h" /* Interface to parser object. */
52 /* Replace the lexer input function. */
54 #define YY_INPUT(buf, result, max_size) \
55 { result = cmDependsFortranParser_Input(yyextra, buf, max_size); }
57 /* Include the set of tokens from the parser. */
58 #include "cmDependsFortranParserTokens.h"
60 /*--------------------------------------------------------------------------*/
74 cmDependsFortranParser_StringStart(yyextra);
75 cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
80 cmDependsFortranParser_StringStart(yyextra);
81 cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
87 BEGIN(cmDependsFortranParser_GetOldStartcond(yyextra) );
88 yylvalp->string = strdup(cmDependsFortranParser_StringEnd(yyextra));
92 <str_dq,str_sq>&[ \t]*\n |
93 <str_dq,str_sq>&[ \t]*\n[ \t]*& /* Ignore (continued strings, free fmt) */
95 <fixed_fmt,str_dq,str_sq>\n[ ]{5}[^ \t\n] {
96 if (cmDependsFortranParser_GetOldStartcond(yyextra) == fixed_fmt)
97 ; /* Ignore (cont. strings, fixed fmt) */
100 unput(yytext[strlen(yytext)-1]);
108 return UNTERMINATED_STRING;
112 cmDependsFortranParser_StringAppend(yyextra, yytext[0]);
115 !.*\n { return EOSTMT; } /* Treat comments like */
116 <fixed_fmt>^[cC*dD].*\n { return EOSTMT; } /* empty lines */
118 ^[ \t]*#[ \t]*include[ \t]*<[^>]+> {
119 yytext[yyleng-1] = 0;
120 yylvalp->string = strdup(strchr(yytext, '<')+1);
121 return CPP_INCLUDE_ANGLE;
123 ^[ \t]*#[ \t]*include { return CPP_INCLUDE; }
124 \$[ \t]*include { return F90PPR_INCLUDE; }
125 \?\?[ \t]*include { return COCO_INCLUDE; }
127 ^[ \t]*#[ \t]*define { return CPP_DEFINE; }
128 \$[ \t]*DEFINE { return F90PPR_DEFINE; }
130 ^[ \t]*#[ \t]*undef { return CPP_UNDEF; }
131 \$[ \t]*UNDEF { return F90PPR_UNDEF; }
133 ^[ \t]*#[ \t]*ifdef { return CPP_IFDEF; }
134 ^[ \t]*#[ \t]*ifndef { return CPP_IFNDEF; }
135 ^[ \t]*#[ \t]*if { return CPP_IF; }
136 ^[ \t]*#[ \t]*elif { return CPP_ELIF; }
137 ^[ \t]*#[ \t]*else { return CPP_ELSE; }
138 ^[ \t]*#[ \t]*endif { return CPP_ENDIF; }
140 $[ \t]*ifdef { return F90PPR_IFDEF; }
141 $[ \t]*ifndef { return F90PPR_IFNDEF; }
142 $[ \t]*if { return F90PPR_IF; }
143 $[ \t]*elif { return F90PPR_ELIF; }
144 $[ \t]*else { return F90PPR_ELSE; }
145 $[ \t]*endif { return F90PPR_ENDIF; }
147 /* Line continuations, possible involving comments. */
153 :: { return DCOLON; }
155 <fixed_fmt>\n[ ]{5}[^ ] { return GARBAGE; }
157 =|=> { return ASSIGNMENT_OP; }
159 [a-zA-Z_][a-zA-Z_0-9]* {
160 yylvalp->string = strdup(yytext);
164 [^ \t\n\r;,!'"a-zA-Z=&]+ { return GARBAGE; }
166 ;|\n { return EOSTMT; }
169 [ \t\r,] /* Ignore */
170 \\[ \t]*\n /* Ignore line-endings preceeded by \ */
172 . { return *yytext; }
175 if(!cmDependsFortranParser_FilePop(yyextra) )
183 /*--------------------------------------------------------------------------*/
184 YY_BUFFER_STATE cmDependsFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
186 /* Hack into the internal flex-generated scanner to get the buffer. */
187 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
188 return YY_CURRENT_BUFFER;