summaryrefslogtreecommitdiffstats
path: root/Source/cmDependsFortranLexer.in.l
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-01-26 20:33:38 (GMT)
committerBrad King <brad.king@kitware.com>2005-01-26 20:33:38 (GMT)
commit19f977bad7261d9e8f8d6c5d2764c079d35cc014 (patch)
treefdafaf2f6202af5d14201fd1b81e9858e9209162 /Source/cmDependsFortranLexer.in.l
parentaaac6f2c3ac9e9f95f0fdad7d77b4de21568ed52 (diff)
downloadCMake-19f977bad7261d9e8f8d6c5d2764c079d35cc014.zip
CMake-19f977bad7261d9e8f8d6c5d2764c079d35cc014.tar.gz
CMake-19f977bad7261d9e8f8d6c5d2764c079d35cc014.tar.bz2
ENH: Added Fortran dependency scanner implementation.
Diffstat (limited to 'Source/cmDependsFortranLexer.in.l')
-rw-r--r--Source/cmDependsFortranLexer.in.l203
1 files changed, 203 insertions, 0 deletions
diff --git a/Source/cmDependsFortranLexer.in.l b/Source/cmDependsFortranLexer.in.l
new file mode 100644
index 0000000..4a6518fb
--- /dev/null
+++ b/Source/cmDependsFortranLexer.in.l
@@ -0,0 +1,203 @@
+%{
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+/*-------------------------------------------------------------------------
+ Portions of this source have been derived from makefdep90 version 2.6.2,
+
+ Copyright (C) 2000,2001 Erik Edelmann <eedelman@beam.helsinki.fi>.
+
+ The code was originally distributed under the GPL but permission
+ from the copyright holder has been obtained to distribute this
+ derived work under the CMake license.
+-------------------------------------------------------------------------*/
+
+/*
+
+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
+
+Modify cmDependsFortranLexer.c:
+ - remove TABs
+ - add a statement "(void)yyscanner;" to the top of 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
+
+*/
+
+#include "cmDependsFortranParser.h" /* Interface to parser object. */
+
+/* Disable some warnings. */
+#if defined(_MSC_VER)
+# pragma warning ( disable : 4127 )
+# pragma warning ( disable : 4131 )
+# pragma warning ( disable : 4244 )
+# pragma warning ( disable : 4251 )
+# pragma warning ( disable : 4267 )
+# pragma warning ( disable : 4305 )
+# pragma warning ( disable : 4309 )
+# pragma warning ( disable : 4706 )
+# pragma warning ( disable : 4786 )
+#endif
+
+/* 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); }
+
+/* Include the set of tokens from the parser. */
+#include "cmDependsFortranParserTokens.h"
+
+/*--------------------------------------------------------------------------*/
+%}
+
+%option reentrant
+%option noyywrap
+%pointer
+
+%s free_fmt fixed_fmt
+%x str_sq str_dq
+
+%%
+
+\" {
+ cmDependsFortranParser_StringStart(yyextra);
+ BEGIN(str_dq);
+}
+
+' {
+ cmDependsFortranParser_StringStart(yyextra);
+ BEGIN(str_sq);
+}
+
+<str_dq>\" |
+<str_sq>' {
+ yylvalp->string = strdup(cmDependsFortranParser_StringEnd(yyextra));
+ return STRING;
+}
+
+<str_dq,str_sq>&[ \t]*\n |
+<str_dq,str_sq>&[ \t]*\n[ \t]*& /* Ignore (continued strings, free fmt) */
+
+<fixed_fmt,str_dq,str_sq>\n[ ]{5}[^ \t\n] /*Ignore (cont. strings, fixed fmt) */
+
+<str_dq,str_sq>\n {
+ unput ('\n');
+ BEGIN(INITIAL);
+ return UNTERMINATED_STRING;
+}
+
+<str_sq,str_dq>. {
+ cmDependsFortranParser_StringAppend(yyextra, yytext[0]);
+}
+
+!.*\n { return EOSTMT; } /* Treat comments like */
+<fixed_fmt>^[cC*dD].*\n { return EOSTMT; } /* empty lines */
+
+#[ \t]*include { return CPP_INCLUDE; }
+\$[ \t]*include { return F90PPR_INCLUDE; }
+\?\?[ \t]*include { return COCO_INCLUDE; }
+INCLUDE { return F_INCLUDE; }
+USE { return USE; }
+
+END" "*INTERFACE {
+ cmDependsFortranParser_SetInInterface(yyextra, 0);
+}
+INTERFACE {
+ cmDependsFortranParser_SetInInterface(yyextra, 1);
+}
+
+END" "*MODULE /* Ignore */
+MODULE {
+ if(!cmDependsFortranParser_GetInInterface(yyextra))
+ {
+ return MODULE;
+ }
+}
+
+#[ \t]*define { return CPP_DEFINE; }
+\$[ \t]*DEFINE { return F90PPR_DEFINE; }
+
+#[ \t]*undef { return CPP_UNDEF; }
+\$[ \t]*UNDEF { return F90PPR_UNDEF; }
+
+#[ \t]*ifdef { return CPP_IFDEF; }
+#[ \t]*ifndef { return CPP_IFNDEF; }
+#[ \t]*if { return CPP_IF; }
+#[ \t]*elif { return CPP_ELIF; }
+#[ \t]*else { return CPP_ELSE; }
+#[ \t]*endif { return CPP_ENDIF; }
+
+$[ \t]*ifdef { return F90PPR_IFDEF; }
+$[ \t]*ifndef { return F90PPR_IFNDEF; }
+$[ \t]*if { return F90PPR_IF; }
+$[ \t]*elif { return F90PPR_ELIF; }
+$[ \t]*else { return F90PPR_ELSE; }
+$[ \t]*endif { return F90PPR_ENDIF; }
+
+&[ \t]*\n |
+&[ \t]*\n[ \t]*& /* Ignore */
+
+
+[^ \t\n\r;,!'""']+ { yylvalp->string = strdup(yytext); return WORD; }
+
+;|\n { return EOSTMT; }
+
+[ \t\r,] /* Ignore */
+
+. { return *yytext; }
+
+<<EOF>> {
+ if(!cmDependsFortranParser_FilePop(yyextra))
+ {
+ return YY_NULL;
+ }
+}
+
+%%
+
+/*--------------------------------------------------------------------------*/
+YY_BUFFER_STATE cmDependsFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
+{
+ /* Hack into the internal flex-generated scanner to get the buffer. */
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return YY_CURRENT_BUFFER;
+}