2 /*=========================================================================
4 Program: CMake - Cross-Platform Makefile Generator
5 Module: $RCSfile: cmDependsFortranLexer.in.l,v $
7 Date: $Date: 2009-06-12 14:46:03 $
8 Version: $Revision: 1.14 $
10 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
11 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
18 /*-------------------------------------------------------------------------
19 Portions of this source have been derived from makedepf90 version 2.8.8,
21 Copyright (C) 2000--2006 Erik Edelmann <erik.edelmann@iki.fi>
23 The code was originally distributed under the GPL but permission
24 from the copyright holder has been obtained to distribute this
25 derived work under the CMake license.
26 -------------------------------------------------------------------------*/
30 This file must be translated to C and modified to build everywhere.
34 flex -i --prefix=cmDependsFortran_yy --header-file=cmDependsFortranLexer.h -ocmDependsFortranLexer.cxx cmDependsFortranLexer.in.l
36 Modify cmDependsFortranLexer.cxx:
38 - remove "yyscanner" argument from these methods:
39 yy_fatal_error, cmDependsFortran_yyalloc, cmDependsFortran_yyrealloc, cmDependsFortran_yyfree
40 - remove "yyscanner = NULL" from end of cmDependsFortran_yylex_destroy
41 - remove all YY_BREAK lines occurring right after return statements
42 - change while ( 1 ) to for(;;)
44 Modify cmDependsFortranLexer.h:
46 - remove the yy_init_globals function
47 - remove the block that includes unistd.h
48 - remove #line directives (avoids bogus warning on old Sun)
52 #include "cmStandardLexer.h"
54 #define cmDependsFortranLexer_cxx
55 #include "cmDependsFortranParser.h" /* Interface to parser object. */
57 /* Replace the lexer input function. */
59 #define YY_INPUT(buf, result, max_size) \
60 { result = cmDependsFortranParser_Input(yyextra, buf, max_size); }
62 /* Include the set of tokens from the parser. */
63 #include "cmDependsFortranParserTokens.h"
65 /*--------------------------------------------------------------------------*/
79 cmDependsFortranParser_StringStart(yyextra);
80 cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
85 cmDependsFortranParser_StringStart(yyextra);
86 cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
92 BEGIN(cmDependsFortranParser_GetOldStartcond(yyextra) );
93 yylvalp->string = strdup(cmDependsFortranParser_StringEnd(yyextra));
97 <str_dq,str_sq>&[ \t]*\n |
98 <str_dq,str_sq>&[ \t]*\n[ \t]*& /* Ignore (continued strings, free fmt) */
100 <fixed_fmt,str_dq,str_sq>\n[ ]{5}[^ \t\n] {
101 if (cmDependsFortranParser_GetOldStartcond(yyextra) == fixed_fmt)
102 ; /* Ignore (cont. strings, fixed fmt) */
105 unput(yytext[strlen(yytext)-1]);
113 return UNTERMINATED_STRING;
117 cmDependsFortranParser_StringAppend(yyextra, yytext[0]);
120 !.*\n { return EOSTMT; } /* Treat comments like */
121 <fixed_fmt>^[cC*dD].*\n { return EOSTMT; } /* empty lines */
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;