2 /*=========================================================================
4 Program: CMake - Cross-Platform Makefile Generator
5 Module: $RCSfile: cmDependsFortranLexer.in.l,v $
7 Date: $Date: 2008-04-24 03:53:20 $
8 Version: $Revision: 1.13 $
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 all YY_BREAK lines occurring right after return statements
41 - change while ( 1 ) to for(;;)
43 Modify cmDependsFortranLexer.h:
45 - remove the yy_init_globals function
46 - remove the block that includes unistd.h
47 - remove #line directives (avoids bogus warning on old Sun)
51 #include "cmStandardLexer.h"
53 #define cmDependsFortranLexer_cxx
54 #include "cmDependsFortranParser.h" /* Interface to parser object. */
56 /* Replace the lexer input function. */
58 #define YY_INPUT(buf, result, max_size) \
59 { result = cmDependsFortranParser_Input(yyextra, buf, max_size); }
61 /* Include the set of tokens from the parser. */
62 #include "cmDependsFortranParserTokens.h"
64 /*--------------------------------------------------------------------------*/
78 cmDependsFortranParser_StringStart(yyextra);
79 cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
84 cmDependsFortranParser_StringStart(yyextra);
85 cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
91 BEGIN(cmDependsFortranParser_GetOldStartcond(yyextra) );
92 yylvalp->string = strdup(cmDependsFortranParser_StringEnd(yyextra));
96 <str_dq,str_sq>&[ \t]*\n |
97 <str_dq,str_sq>&[ \t]*\n[ \t]*& /* Ignore (continued strings, free fmt) */
99 <fixed_fmt,str_dq,str_sq>\n[ ]{5}[^ \t\n] {
100 if (cmDependsFortranParser_GetOldStartcond(yyextra) == fixed_fmt)
101 ; /* Ignore (cont. strings, fixed fmt) */
104 unput(yytext[strlen(yytext)-1]);
112 return UNTERMINATED_STRING;
116 cmDependsFortranParser_StringAppend(yyextra, yytext[0]);
119 !.*\n { return EOSTMT; } /* Treat comments like */
120 <fixed_fmt>^[cC*dD].*\n { return EOSTMT; } /* empty lines */
122 ^[ \t]*#[ \t]*include { return CPP_INCLUDE; }
123 \$[ \t]*include { return F90PPR_INCLUDE; }
124 \?\?[ \t]*include { return COCO_INCLUDE; }
126 ^[ \t]*#[ \t]*define { return CPP_DEFINE; }
127 \$[ \t]*DEFINE { return F90PPR_DEFINE; }
129 ^[ \t]*#[ \t]*undef { return CPP_UNDEF; }
130 \$[ \t]*UNDEF { return F90PPR_UNDEF; }
132 ^[ \t]*#[ \t]*ifdef { return CPP_IFDEF; }
133 ^[ \t]*#[ \t]*ifndef { return CPP_IFNDEF; }
134 ^[ \t]*#[ \t]*if { return CPP_IF; }
135 ^[ \t]*#[ \t]*elif { return CPP_ELIF; }
136 ^[ \t]*#[ \t]*else { return CPP_ELSE; }
137 ^[ \t]*#[ \t]*endif { return CPP_ENDIF; }
139 $[ \t]*ifdef { return F90PPR_IFDEF; }
140 $[ \t]*ifndef { return F90PPR_IFNDEF; }
141 $[ \t]*if { return F90PPR_IF; }
142 $[ \t]*elif { return F90PPR_ELIF; }
143 $[ \t]*else { return F90PPR_ELSE; }
144 $[ \t]*endif { return F90PPR_ENDIF; }
146 /* Line continuations, possible involving comments. */
152 :: { return DCOLON; }
154 <fixed_fmt>\n[ ]{5}[^ ] { return GARBAGE; }
156 =|=> { return ASSIGNMENT_OP; }
158 [a-zA-Z_][a-zA-Z_0-9]* {
159 yylvalp->string = strdup(yytext);
163 [^ \t\n\r;,!'"a-zA-Z=&]+ { return GARBAGE; }
165 ;|\n { return EOSTMT; }
168 [ \t\r,] /* Ignore */
169 \\[ \t]*\n /* Ignore line-endings preceeded by \ */
171 . { return *yytext; }
174 if(!cmDependsFortranParser_FilePop(yyextra) )
182 /*--------------------------------------------------------------------------*/
183 YY_BUFFER_STATE cmDependsFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
185 /* Hack into the internal flex-generated scanner to get the buffer. */
186 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
187 return YY_CURRENT_BUFFER;