Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmDependsFortranLexer.in.l
blob488d349d18e55cd3a5900cebc731a9a630ab40a1
1 %{
2 /*=========================================================================
4   Program:   CMake - Cross-Platform Makefile Generator
5   Module:    $RCSfile: cmDependsFortranLexer.in.l,v $
6   Language:  C++
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.
32 Run flex like this:
34   flex -i --prefix=cmDependsFortran_yy --header-file=cmDependsFortranLexer.h -ocmDependsFortranLexer.cxx cmDependsFortranLexer.in.l
36 Modify cmDependsFortranLexer.cxx:
37   - remove TABs
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:
44   - remove TABs
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.  */
57 #undef YY_INPUT
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 /*--------------------------------------------------------------------------*/
68 %option reentrant
69 %option noyywrap
70 %pointer
72 %s free_fmt fixed_fmt
73 %x str_sq str_dq
77 \"              {
78   cmDependsFortranParser_StringStart(yyextra);
79   cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
80   BEGIN(str_dq);
83 '               {
84   cmDependsFortranParser_StringStart(yyextra);
85   cmDependsFortranParser_SetOldStartcond(yyextra, YY_START);
86   BEGIN(str_sq);
89 <str_dq>\" |
90 <str_sq>'  {
91   BEGIN(cmDependsFortranParser_GetOldStartcond(yyextra) );
92   yylvalp->string = strdup(cmDependsFortranParser_StringEnd(yyextra));
93   return STRING;
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) */
102   else
103     {
104     unput(yytext[strlen(yytext)-1]);
105     }
109 <str_dq,str_sq>\n {
110   unput ('\n');
111   BEGIN(INITIAL);
112   return UNTERMINATED_STRING;
115 <str_sq,str_dq>. {
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.  */
147 &([ \t\n]*|!.*)*
148 &([ \t\n]*|!.*)*&
150 , { return COMMA; }
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);
160   return WORD;
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; }
173 <<EOF>> {
174   if(!cmDependsFortranParser_FilePop(yyextra) )
175     {
176     return YY_NULL;
177     }
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;