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 bison --yacc --name-prefix=cmDependsFortran_yy
30 --defines=cmDependsFortranParserTokens.h
31 -ocmDependsFortranParser.cxx
32 cmDependsFortranParser.y
34 Modify cmDependsFortranParser.cxx:
36 - remove use of the 'register' storage class specifier
37 - Remove the yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
40 /*-------------------------------------------------------------------------*/
41 #define cmDependsFortranParser_cxx
42 #include "cmDependsFortranParser.h" /* Interface to parser object. */
43 #include "cmDependsFortranParserTokens.h" /* Need YYSTYPE for YY_DECL. */
45 #include <cmsys/String.h>
47 /* Configure the parser to use a lexer object. */
48 #define YYPARSE_PARAM yyscanner
49 #define YYLEX_PARAM yyscanner
50 #define YYERROR_VERBOSE 1
51 #define cmDependsFortran_yyerror(x) \
52 cmDependsFortranError(yyscanner, x)
54 /* Forward declare the lexer entry point. */
57 /* Helper function to forward error callback. */
58 static void cmDependsFortranError(yyscan_t yyscanner, const char* message)
60 cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
61 cmDependsFortranParser_Error(parser, message);
64 static bool cmDependsFortranParserIsKeyword(const char* word,
67 return cmsysString_strcasecmp(word, keyword) == 0;
70 /* Disable some warnings in the generated code. */
72 # pragma warn -8004 /* Variable assigned a value that is not used. */
73 # pragma warn -8008 /* condition always returns true */
74 # pragma warn -8060 /* possibly incorrect assignment */
75 # pragma warn -8066 /* unreachable code */
78 # pragma warning (disable: 4102) /* Unused goto label. */
79 # pragma warning (disable: 4065) /* Switch contains default but no case. */
80 # pragma warning (disable: 4701) /* Local variable may not be initialized. */
81 # pragma warning (disable: 4702) /* Unreachable code. */
82 # pragma warning (disable: 4127) /* Conditional expression is constant. */
83 # pragma warning (disable: 4244) /* Conversion to smaller type, data loss. */
87 /* Generate a reentrant parser object. */
94 /*-------------------------------------------------------------------------*/
96 %token EOSTMT ASSIGNMENT_OP GARBAGE
97 %token CPP_INCLUDE F90PPR_INCLUDE COCO_INCLUDE
98 %token F90PPR_DEFINE CPP_DEFINE F90PPR_UNDEF CPP_UNDEF
99 %token CPP_IFDEF CPP_IFNDEF CPP_IF CPP_ELSE CPP_ELIF CPP_ENDIF
100 %token F90PPR_IFDEF F90PPR_IFNDEF F90PPR_IF
101 %token F90PPR_ELSE F90PPR_ELIF F90PPR_ENDIF
103 %token <string> CPP_TOENDL
104 %token <number> UNTERMINATED_STRING
105 %token <string> STRING WORD
106 %token <string> CPP_INCLUDE_ANGLE
108 /*-------------------------------------------------------------------------*/
112 code: /* empty */ | code stmt;
114 stmt: keyword_stmt | assignment_stmt;
116 assignment_stmt: WORD ASSIGNMENT_OP other EOSTMT /* Ignore */
124 if (cmDependsFortranParserIsKeyword($1, "interface"))
126 cmDependsFortranParser* parser =
127 cmDependsFortran_yyget_extra(yyscanner);
128 cmDependsFortranParser_SetInInterface(parser, true);
132 | WORD WORD other EOSTMT
134 if (cmDependsFortranParserIsKeyword($1, "use"))
136 cmDependsFortranParser* parser =
137 cmDependsFortran_yyget_extra(yyscanner);
138 cmDependsFortranParser_RuleUse(parser, $2);
140 else if (cmDependsFortranParserIsKeyword($1, "module"))
142 cmDependsFortranParser* parser =
143 cmDependsFortran_yyget_extra(yyscanner);
144 cmDependsFortranParser_RuleModule(parser, $2);
146 else if (cmDependsFortranParserIsKeyword($1, "interface"))
148 cmDependsFortranParser* parser =
149 cmDependsFortran_yyget_extra(yyscanner);
150 cmDependsFortranParser_SetInInterface(parser, true);
152 else if (cmDependsFortranParserIsKeyword($2, "interface") &&
153 cmDependsFortranParserIsKeyword($1, "end"))
155 cmDependsFortranParser* parser =
156 cmDependsFortran_yyget_extra(yyscanner);
157 cmDependsFortranParser_SetInInterface(parser, false);
162 | WORD DCOLON WORD other EOSTMT
164 if (cmDependsFortranParserIsKeyword($1, "use"))
166 cmDependsFortranParser* parser =
167 cmDependsFortran_yyget_extra(yyscanner);
168 cmDependsFortranParser_RuleUse(parser, $3);
173 | WORD COMMA WORD DCOLON WORD other EOSTMT
175 if (cmDependsFortranParserIsKeyword($1, "use") &&
176 cmDependsFortranParserIsKeyword($3, "non_intrinsic") )
178 cmDependsFortranParser* parser =
179 cmDependsFortran_yyget_extra(yyscanner);
180 cmDependsFortranParser_RuleUse(parser, $5);
186 | WORD STRING other EOSTMT /* Ignore */
188 if (cmDependsFortranParserIsKeyword($1, "include"))
190 cmDependsFortranParser* parser =
191 cmDependsFortran_yyget_extra(yyscanner);
192 cmDependsFortranParser_RuleInclude(parser, $2);
197 | CPP_INCLUDE_ANGLE other EOSTMT
199 cmDependsFortranParser* parser =
200 cmDependsFortran_yyget_extra(yyscanner);
201 cmDependsFortranParser_RuleInclude(parser, $1);
204 | include STRING other EOSTMT
206 cmDependsFortranParser* parser =
207 cmDependsFortran_yyget_extra(yyscanner);
208 cmDependsFortranParser_RuleInclude(parser, $2);
211 | define WORD other EOSTMT
213 cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
214 cmDependsFortranParser_RuleDefine(parser, $2);
217 | undef WORD other EOSTMT
219 cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
220 cmDependsFortranParser_RuleUndef(parser, $2);
223 | ifdef WORD other EOSTMT
225 cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
226 cmDependsFortranParser_RuleIfdef(parser, $2);
229 | ifndef WORD other EOSTMT
231 cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
232 cmDependsFortranParser_RuleIfndef(parser, $2);
237 cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
238 cmDependsFortranParser_RuleIf(parser);
242 cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
243 cmDependsFortranParser_RuleElif(parser);
247 cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
248 cmDependsFortranParser_RuleElse(parser);
252 cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
253 cmDependsFortranParser_RuleEndif(parser);
255 | WORD GARBAGE other EOSTMT /* Ignore */
259 | GARBAGE other EOSTMT
266 include: CPP_INCLUDE | F90PPR_INCLUDE | COCO_INCLUDE ;
267 define: CPP_DEFINE | F90PPR_DEFINE;
268 undef: CPP_UNDEF | F90PPR_UNDEF ;
269 ifdef: CPP_IFDEF | F90PPR_IFDEF ;
270 ifndef: CPP_IFNDEF | F90PPR_IFNDEF ;
271 if: CPP_IF | F90PPR_IF ;
272 elif: CPP_ELIF | F90PPR_ELIF ;
273 else: CPP_ELSE | F90PPR_ELSE ;
274 endif: CPP_ENDIF | F90PPR_ENDIF ;
275 other: /* empty */ | other misc_code ;
279 | STRING { free ($1); }
284 | UNTERMINATED_STRING