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 use of the 'register' storage class specifier
34 - remove "yyscanner" argument from these methods:
35 yy_fatal_error, cmDependsFortran_yyalloc, cmDependsFortran_yyrealloc, cmDependsFortran_yyfree
36 - remove "yyscanner = NULL" from end of cmDependsFortran_yylex_destroy
37 - remove all YY_BREAK lines occurring right after return statements
38 - change while ( 1 ) to for(;;)
40 Modify cmDependsFortranLexer.h:
42 - remove the yy_init_globals function
43 - remove the block that includes unistd.h
44 - remove #line directives (avoids bogus warning on old Sun)
48 #include "cmStandardLexer.h"
50 #define cmDependsFortranLexer_cxx
51 #include "cmDependsFortranParser.h" /* Interface to parser object. */
53 /* Replace the lexer input function. */
55 #define YY_INPUT(buf, result, max_size) \
56 { result = cmDependsFortranParser_Input(yyextra, buf, max_size); }
58 /* Include the set of tokens from the parser. */
59 #include "cmDependsFortranParserTokens.h"
61 /*--------------------------------------------------------------------------*/
75 cmDependsFortranParser_StringStart(yyextra);
76 cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
81 cmDependsFortranParser_StringStart(yyextra);
82 cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
88 BEGIN(cmDependsFortranParser_GetOldStartcond(yyextra) );
89 yylvalp->string = strdup(cmDependsFortranParser_StringEnd(yyextra));
93 <str_dq,str_sq>&[ \t]*\n |
94 <str_dq,str_sq>&[ \t]*\n[ \t]*& /* Ignore (continued strings, free fmt) */
96 <fixed_fmt,str_dq,str_sq>\n[ ]{5}[^ \t\n] {
97 if (cmDependsFortranParser_GetOldStartcond(yyextra) == fixed_fmt)
98 ; /* Ignore (cont. strings, fixed fmt) */
101 unput(yytext[strlen(yytext)-1]);
109 return UNTERMINATED_STRING;
113 cmDependsFortranParser_StringAppend(yyextra, yytext[0]);
116 !.*\n { return EOSTMT; } /* Treat comments like */
117 <fixed_fmt>^[cC*dD].*\n { return EOSTMT; } /* empty lines */
119 ^[ \t]*#[ \t]*include[ \t]*<[^>]+> {
120 yytext[yyleng-1] = 0;
121 yylvalp->string = strdup(strchr(yytext, '<')+1);
122 return CPP_INCLUDE_ANGLE;
124 ^[ \t]*#[ \t]*include { return CPP_INCLUDE; }
125 \$[ \t]*include { return F90PPR_INCLUDE; }
126 \?\?[ \t]*include { return COCO_INCLUDE; }
128 ^[ \t]*#[ \t]*define { return CPP_DEFINE; }
129 \$[ \t]*DEFINE { return F90PPR_DEFINE; }
131 ^[ \t]*#[ \t]*undef { return CPP_UNDEF; }
132 \$[ \t]*UNDEF { return F90PPR_UNDEF; }
134 ^[ \t]*#[ \t]*ifdef { return CPP_IFDEF; }
135 ^[ \t]*#[ \t]*ifndef { return CPP_IFNDEF; }
136 ^[ \t]*#[ \t]*if { return CPP_IF; }
137 ^[ \t]*#[ \t]*elif { return CPP_ELIF; }
138 ^[ \t]*#[ \t]*else { return CPP_ELSE; }
139 ^[ \t]*#[ \t]*endif { return CPP_ENDIF; }
141 $[ \t]*ifdef { return F90PPR_IFDEF; }
142 $[ \t]*ifndef { return F90PPR_IFNDEF; }
143 $[ \t]*if { return F90PPR_IF; }
144 $[ \t]*elif { return F90PPR_ELIF; }
145 $[ \t]*else { return F90PPR_ELSE; }
146 $[ \t]*endif { return F90PPR_ENDIF; }
148 /* Line continuations, possible involving comments. */
154 :: { return DCOLON; }
156 <fixed_fmt>\n[ ]{5}[^ ] { return GARBAGE; }
158 =|=> { return ASSIGNMENT_OP; }
160 [a-zA-Z_][a-zA-Z_0-9]* {
161 yylvalp->string = strdup(yytext);
165 [^ \t\n\r;,!'"a-zA-Z=&]+ { return GARBAGE; }
167 ;|\n { return EOSTMT; }
170 [ \t\r,] /* Ignore */
171 \\[ \t]*\n /* Ignore line-endings preceeded by \ */
173 . { return *yytext; }
176 if(!cmDependsFortranParser_FilePop(yyextra) )
184 /*--------------------------------------------------------------------------*/
185 YY_BUFFER_STATE cmDependsFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
187 /* Hack into the internal flex-generated scanner to get the buffer. */
188 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
189 return YY_CURRENT_BUFFER;