Merge remote-tracking branch 'origin/release-v4.5.2'
[WRF.git] / var / da / makedepf90-2.8.8 / find_dep.c
blobab8a01fa8cdebeaedc7fee012ea59deb85b658a9
1 /* A Bison parser, made by GNU Bison 2.1. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
36 /* Identify Bison output. */
37 #define YYBISON 1
39 /* Bison version. */
40 #define YYBISON_VERSION "2.1"
42 /* Skeleton name. */
43 #define YYSKELETON_NAME "yacc.c"
45 /* Pure parsers. */
46 #define YYPURE 0
48 /* Using locations. */
49 #define YYLSP_NEEDED 0
53 /* Tokens. */
54 #ifndef YYTOKENTYPE
55 # define YYTOKENTYPE
56 /* Put the tokens into the symbol table, so that GDB and other debuggers
57 know about them. */
58 enum yytokentype {
59 EOSTMT = 258,
60 ASSIGNMENT_OP = 259,
61 GARBAGE = 260,
62 CPP_INCLUDE = 261,
63 F90PPR_INCLUDE = 262,
64 COCO_INCLUDE = 263,
65 F90PPR_DEFINE = 264,
66 CPP_DEFINE = 265,
67 F90PPR_UNDEF = 266,
68 CPP_UNDEF = 267,
69 CPP_IFDEF = 268,
70 CPP_IFNDEF = 269,
71 CPP_IF = 270,
72 CPP_ELSE = 271,
73 CPP_ELIF = 272,
74 CPP_ENDIF = 273,
75 F90PPR_IFDEF = 274,
76 F90PPR_IFNDEF = 275,
77 F90PPR_IF = 276,
78 F90PPR_ELSE = 277,
79 F90PPR_ELIF = 278,
80 F90PPR_ENDIF = 279,
81 CPP_TOENDL = 280,
82 UNTERMINATED_STRING = 281,
83 STRING = 282,
84 WORD = 283
86 #endif
87 /* Tokens. */
88 #define EOSTMT 258
89 #define ASSIGNMENT_OP 259
90 #define GARBAGE 260
91 #define CPP_INCLUDE 261
92 #define F90PPR_INCLUDE 262
93 #define COCO_INCLUDE 263
94 #define F90PPR_DEFINE 264
95 #define CPP_DEFINE 265
96 #define F90PPR_UNDEF 266
97 #define CPP_UNDEF 267
98 #define CPP_IFDEF 268
99 #define CPP_IFNDEF 269
100 #define CPP_IF 270
101 #define CPP_ELSE 271
102 #define CPP_ELIF 272
103 #define CPP_ENDIF 273
104 #define F90PPR_IFDEF 274
105 #define F90PPR_IFNDEF 275
106 #define F90PPR_IF 276
107 #define F90PPR_ELSE 277
108 #define F90PPR_ELIF 278
109 #define F90PPR_ENDIF 279
110 #define CPP_TOENDL 280
111 #define UNTERMINATED_STRING 281
112 #define STRING 282
113 #define WORD 283
118 /* Copy the first part of user declarations. */
119 #line 1 "find_dep.y"
122 * Copyright (C) 2000-2006 Erik Edelmann <Erik.Edelmann@iki.fi>
124 * This program is free software; you can redistribute it
125 * and/or modify it under the terms of the GNU General Public
126 * License version 2 as published by the Free Software
127 * Foundation.
129 * This program is distributed in the hope that it will be
130 * useful, but WITHOUT ANY WARRANTY; without even the implied
131 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
132 * PURPOSE. See the GNU General Public License for more
133 * details.
135 * You should have received a copy of the GNU General Public
136 * License along with this program; if not, write to the Free
137 * Software Foundation, Inc., 59 Temple Place, Suite 330,
138 * Boston, MA 02111-1307 USA
141 #include <errno.h>
142 #include <string.h>
143 #include <stdio.h>
144 #include <stdlib.h>
146 #ifdef HAVE_ALLOCA_H
147 # include <alloca.h>
148 #endif
150 #include "finddep.h"
151 #include "utils.h"
152 #include "errormesg.h"
153 #include "global.h"
154 #include "macro.h"
155 #include "modfile_name.h"
157 static char *sourcefile;
158 static char *curr_file;
159 static Dependency *dep; /* Dependencies of the file */
160 static List *modules; /* Modules defined in the file */
161 static List *macrolist;
162 static char *filestack[INCLUDE_RECURSION_LIMIT+1];
163 static int filestack_i;
164 static int pp_ignore; /* In 'false'-branch of a pre-processor 'if' */
165 static bool skip_to_end[20];
166 static int skip_i;
167 static bool in_interface = false;
169 int yyerror(const char *s);
171 static int modcmp(const void *m1, const void *m2);
172 SourceFmt get_format(const char *filename);
173 void handle_include(const char *incfile);
175 Macro *defmac;
177 /* Defined in lexer.l */
178 int yylex();
179 bool lex_include_file(const char *incfile);
180 void lex_set_format(SourceFmt fmt);
184 /* Enabling traces. */
185 #ifndef YYDEBUG
186 # define YYDEBUG 0
187 #endif
189 /* Enabling verbose error messages. */
190 #ifdef YYERROR_VERBOSE
191 # undef YYERROR_VERBOSE
192 # define YYERROR_VERBOSE 1
193 #else
194 # define YYERROR_VERBOSE 0
195 #endif
197 /* Enabling the token table. */
198 #ifndef YYTOKEN_TABLE
199 # define YYTOKEN_TABLE 0
200 #endif
202 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
203 #line 65 "find_dep.y"
204 typedef union YYSTYPE {
205 char *string;
206 int number;
207 } YYSTYPE;
208 /* Line 196 of yacc.c. */
209 #line 210 "y.tab.c"
210 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
211 # define YYSTYPE_IS_DECLARED 1
212 # define YYSTYPE_IS_TRIVIAL 1
213 #endif
217 /* Copy the second part of user declarations. */
220 /* Line 219 of yacc.c. */
221 #line 222 "y.tab.c"
223 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
224 # define YYSIZE_T __SIZE_TYPE__
225 #endif
226 #if ! defined (YYSIZE_T) && defined (size_t)
227 # define YYSIZE_T size_t
228 #endif
229 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
230 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
231 # define YYSIZE_T size_t
232 #endif
233 #if ! defined (YYSIZE_T)
234 # define YYSIZE_T unsigned int
235 #endif
237 #ifndef YY_
238 # if YYENABLE_NLS
239 # if ENABLE_NLS
240 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
241 # define YY_(msgid) dgettext ("bison-runtime", msgid)
242 # endif
243 # endif
244 # ifndef YY_
245 # define YY_(msgid) msgid
246 # endif
247 #endif
249 #if ! defined (yyoverflow) || YYERROR_VERBOSE
251 /* The parser invokes alloca or malloc; define the necessary symbols. */
253 # ifdef YYSTACK_USE_ALLOCA
254 # if YYSTACK_USE_ALLOCA
255 # ifdef __GNUC__
256 # define YYSTACK_ALLOC __builtin_alloca
257 # else
258 # define YYSTACK_ALLOC alloca
259 # if defined (__STDC__) || defined (__cplusplus)
260 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
261 # define YYINCLUDED_STDLIB_H
262 # endif
263 # endif
264 # endif
265 # endif
267 # ifdef YYSTACK_ALLOC
268 /* Pacify GCC's `empty if-body' warning. */
269 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
270 # ifndef YYSTACK_ALLOC_MAXIMUM
271 /* The OS might guarantee only one guard page at the bottom of the stack,
272 and a page size can be as small as 4096 bytes. So we cannot safely
273 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
274 to allow for a few compiler-allocated temporary stack slots. */
275 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
276 # endif
277 # else
278 # define YYSTACK_ALLOC YYMALLOC
279 # define YYSTACK_FREE YYFREE
280 # ifndef YYSTACK_ALLOC_MAXIMUM
281 # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
282 # endif
283 # ifdef __cplusplus
284 extern "C" {
285 # endif
286 # ifndef YYMALLOC
287 # define YYMALLOC malloc
288 # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
289 && (defined (__STDC__) || defined (__cplusplus)))
290 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
291 # endif
292 # endif
293 # ifndef YYFREE
294 # define YYFREE free
295 # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
296 && (defined (__STDC__) || defined (__cplusplus)))
297 void free (void *); /* INFRINGES ON USER NAME SPACE */
298 # endif
299 # endif
300 # ifdef __cplusplus
302 # endif
303 # endif
304 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
307 #if (! defined (yyoverflow) \
308 && (! defined (__cplusplus) \
309 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
311 /* A type that is properly aligned for any stack member. */
312 union yyalloc
314 short int yyss;
315 YYSTYPE yyvs;
318 /* The size of the maximum gap between one aligned stack and the next. */
319 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
321 /* The size of an array large to enough to hold all stacks, each with
322 N elements. */
323 # define YYSTACK_BYTES(N) \
324 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
325 + YYSTACK_GAP_MAXIMUM)
327 /* Copy COUNT objects from FROM to TO. The source and destination do
328 not overlap. */
329 # ifndef YYCOPY
330 # if defined (__GNUC__) && 1 < __GNUC__
331 # define YYCOPY(To, From, Count) \
332 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
333 # else
334 # define YYCOPY(To, From, Count) \
335 do \
337 YYSIZE_T yyi; \
338 for (yyi = 0; yyi < (Count); yyi++) \
339 (To)[yyi] = (From)[yyi]; \
341 while (0)
342 # endif
343 # endif
345 /* Relocate STACK from its old location to the new one. The
346 local variables YYSIZE and YYSTACKSIZE give the old and new number of
347 elements in the stack, and YYPTR gives the new location of the
348 stack. Advance YYPTR to a properly aligned location for the next
349 stack. */
350 # define YYSTACK_RELOCATE(Stack) \
351 do \
353 YYSIZE_T yynewbytes; \
354 YYCOPY (&yyptr->Stack, Stack, yysize); \
355 Stack = &yyptr->Stack; \
356 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
357 yyptr += yynewbytes / sizeof (*yyptr); \
359 while (0)
361 #endif
363 #if defined (__STDC__) || defined (__cplusplus)
364 typedef signed char yysigned_char;
365 #else
366 typedef short int yysigned_char;
367 #endif
369 /* YYFINAL -- State number of the termination state. */
370 #define YYFINAL 2
371 /* YYLAST -- Last index in YYTABLE. */
372 #define YYLAST 142
374 /* YYNTOKENS -- Number of terminals. */
375 #define YYNTOKENS 29
376 /* YYNNTS -- Number of nonterminals. */
377 #define YYNNTS 16
378 /* YYNRULES -- Number of rules. */
379 #define YYNRULES 49
380 /* YYNRULES -- Number of states. */
381 #define YYNSTATES 85
383 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
384 #define YYUNDEFTOK 2
385 #define YYMAXUTOK 283
387 #define YYTRANSLATE(YYX) \
388 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
390 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
391 static const unsigned char yytranslate[] =
393 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
394 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
395 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
396 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
397 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
398 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
399 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
400 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
401 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
402 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
403 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
404 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
405 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
406 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
407 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
408 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
409 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
410 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
411 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
412 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
419 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
420 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
421 25, 26, 27, 28
424 #if YYDEBUG
425 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
426 YYRHS. */
427 static const unsigned char yyprhs[] =
429 0, 0, 3, 4, 7, 9, 11, 16, 19, 24,
430 29, 34, 39, 44, 49, 54, 59, 63, 67, 71,
431 75, 80, 84, 86, 88, 90, 92, 94, 96, 98,
432 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
433 120, 122, 124, 126, 127, 130, 132, 134, 136, 138
436 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
437 static const yysigned_char yyrhs[] =
439 30, 0, -1, -1, 30, 31, -1, 33, -1, 32,
440 -1, 28, 4, 43, 3, -1, 28, 3, -1, 28,
441 28, 43, 3, -1, 28, 27, 43, 3, -1, 34,
442 27, 43, 3, -1, 6, 5, 43, 3, -1, 35,
443 28, 43, 3, -1, 36, 28, 43, 3, -1, 37,
444 28, 43, 3, -1, 38, 28, 43, 3, -1, 39,
445 43, 3, -1, 40, 43, 3, -1, 41, 43, 3,
446 -1, 42, 43, 3, -1, 28, 5, 43, 3, -1,
447 5, 43, 3, -1, 3, -1, 1, -1, 6, -1,
448 7, -1, 8, -1, 10, -1, 9, -1, 12, -1,
449 11, -1, 13, -1, 19, -1, 14, -1, 20, -1,
450 15, -1, 21, -1, 17, -1, 23, -1, 16, -1,
451 22, -1, 18, -1, 24, -1, -1, 43, 44, -1,
452 28, -1, 27, -1, 5, -1, 4, -1, 26, -1
455 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
456 static const unsigned short int yyrline[] =
458 0, 81, 81, 82, 85, 86, 89, 91, 96, 136,
459 143, 147, 148, 157, 174, 190, 206, 214, 219, 225,
460 230, 231, 232, 233, 236, 237, 238, 241, 242, 245,
461 246, 249, 250, 253, 254, 257, 258, 261, 262, 265,
462 266, 269, 270, 273, 274, 277, 278, 279, 280, 281
464 #endif
466 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
467 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
468 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
469 static const char *const yytname[] =
471 "$end", "error", "$undefined", "EOSTMT", "ASSIGNMENT_OP", "GARBAGE",
472 "CPP_INCLUDE", "F90PPR_INCLUDE", "COCO_INCLUDE", "F90PPR_DEFINE",
473 "CPP_DEFINE", "F90PPR_UNDEF", "CPP_UNDEF", "CPP_IFDEF", "CPP_IFNDEF",
474 "CPP_IF", "CPP_ELSE", "CPP_ELIF", "CPP_ENDIF", "F90PPR_IFDEF",
475 "F90PPR_IFNDEF", "F90PPR_IF", "F90PPR_ELSE", "F90PPR_ELIF",
476 "F90PPR_ENDIF", "CPP_TOENDL", "UNTERMINATED_STRING", "STRING", "WORD",
477 "$accept", "code", "stmt", "assignment_stmt", "keyword_stmt", "include",
478 "define", "undef", "ifdef", "ifndef", "if", "elif", "else", "endif",
479 "other", "misc_code", 0
481 #endif
483 # ifdef YYPRINT
484 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
485 token YYLEX-NUM. */
486 static const unsigned short int yytoknum[] =
488 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
489 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
490 275, 276, 277, 278, 279, 280, 281, 282, 283
492 # endif
494 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
495 static const unsigned char yyr1[] =
497 0, 29, 30, 30, 31, 31, 32, 33, 33, 33,
498 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
499 33, 33, 33, 33, 34, 34, 34, 35, 35, 36,
500 36, 37, 37, 38, 38, 39, 39, 40, 40, 41,
501 41, 42, 42, 43, 43, 44, 44, 44, 44, 44
504 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
505 static const unsigned char yyr2[] =
507 0, 2, 0, 2, 1, 1, 4, 2, 4, 4,
508 4, 4, 4, 4, 4, 4, 3, 3, 3, 3,
509 4, 3, 1, 1, 1, 1, 1, 1, 1, 1,
510 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
511 1, 1, 1, 0, 2, 1, 1, 1, 1, 1
514 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
515 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
516 means the default is an error. */
517 static const unsigned char yydefact[] =
519 2, 0, 1, 23, 22, 43, 24, 25, 26, 28,
520 27, 30, 29, 31, 33, 35, 39, 37, 41, 32,
521 34, 36, 40, 38, 42, 0, 3, 5, 4, 0,
522 0, 0, 0, 0, 43, 43, 43, 43, 0, 43,
523 7, 43, 43, 43, 43, 43, 43, 43, 43, 43,
524 0, 0, 0, 0, 21, 48, 47, 49, 46, 45,
525 44, 0, 0, 0, 0, 0, 0, 0, 0, 0,
526 0, 16, 17, 18, 19, 11, 6, 20, 9, 8,
527 10, 12, 13, 14, 15
530 /* YYDEFGOTO[NTERM-NUM]. */
531 static const yysigned_char yydefgoto[] =
533 -1, 1, 26, 27, 28, 29, 30, 31, 32, 33,
534 34, 35, 36, 37, 38, 60
537 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
538 STATE-NUM. */
539 #define YYPACT_NINF -24
540 static const yysigned_char yypact[] =
542 -24, 0, -24, -24, -24, -24, -3, -24, -24, -24,
543 -24, -24, -24, -24, -24, -24, -24, -24, -24, -24,
544 -24, -24, -24, -24, -24, 114, -24, -24, -24, -23,
545 19, 23, 63, 64, -24, -24, -24, -24, 22, -24,
546 -24, -24, -24, -24, -24, -24, -24, -24, -24, -24,
547 26, 29, 32, 35, -24, -24, -24, -24, -24, -24,
548 -24, 38, 41, 67, 70, 73, 76, 79, 82, 85,
549 111, -24, -24, -24, -24, -24, -24, -24, -24, -24,
550 -24, -24, -24, -24, -24
553 /* YYPGOTO[NTERM-NUM]. */
554 static const yysigned_char yypgoto[] =
556 -24, -24, -24, -24, -24, -24, -24, -24, -24, -24,
557 -24, -24, -24, -24, 86, -24
560 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
561 positive, shift that token. If negative, reduce the rule which
562 number is the opposite. If zero, do what YYDEFACT says.
563 If YYTABLE_NINF, syntax error. */
564 #define YYTABLE_NINF -1
565 static const unsigned char yytable[] =
567 2, 3, 39, 4, 45, 5, 6, 7, 8, 9,
568 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
569 20, 21, 22, 23, 24, 54, 55, 56, 25, 71,
570 55, 56, 72, 55, 56, 73, 55, 56, 74, 55,
571 56, 75, 55, 56, 76, 55, 56, 46, 57, 58,
572 59, 47, 57, 58, 59, 57, 58, 59, 57, 58,
573 59, 57, 58, 59, 57, 58, 59, 57, 58, 59,
574 77, 55, 56, 78, 55, 56, 79, 55, 56, 80,
575 55, 56, 81, 55, 56, 82, 55, 56, 83, 55,
576 56, 48, 49, 57, 58, 59, 57, 58, 59, 57,
577 58, 59, 57, 58, 59, 57, 58, 59, 57, 58,
578 59, 57, 58, 59, 84, 55, 56, 40, 41, 42,
579 50, 51, 52, 53, 0, 61, 0, 62, 63, 64,
580 65, 66, 67, 68, 69, 70, 0, 57, 58, 59,
581 0, 43, 44
584 static const yysigned_char yycheck[] =
586 0, 1, 5, 3, 27, 5, 6, 7, 8, 9,
587 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
588 20, 21, 22, 23, 24, 3, 4, 5, 28, 3,
589 4, 5, 3, 4, 5, 3, 4, 5, 3, 4,
590 5, 3, 4, 5, 3, 4, 5, 28, 26, 27,
591 28, 28, 26, 27, 28, 26, 27, 28, 26, 27,
592 28, 26, 27, 28, 26, 27, 28, 26, 27, 28,
593 3, 4, 5, 3, 4, 5, 3, 4, 5, 3,
594 4, 5, 3, 4, 5, 3, 4, 5, 3, 4,
595 5, 28, 28, 26, 27, 28, 26, 27, 28, 26,
596 27, 28, 26, 27, 28, 26, 27, 28, 26, 27,
597 28, 26, 27, 28, 3, 4, 5, 3, 4, 5,
598 34, 35, 36, 37, -1, 39, -1, 41, 42, 43,
599 44, 45, 46, 47, 48, 49, -1, 26, 27, 28,
600 -1, 27, 28
603 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
604 symbol of state STATE-NUM. */
605 static const unsigned char yystos[] =
607 0, 30, 0, 1, 3, 5, 6, 7, 8, 9,
608 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
609 20, 21, 22, 23, 24, 28, 31, 32, 33, 34,
610 35, 36, 37, 38, 39, 40, 41, 42, 43, 5,
611 3, 4, 5, 27, 28, 27, 28, 28, 28, 28,
612 43, 43, 43, 43, 3, 4, 5, 26, 27, 28,
613 44, 43, 43, 43, 43, 43, 43, 43, 43, 43,
614 43, 3, 3, 3, 3, 3, 3, 3, 3, 3,
615 3, 3, 3, 3, 3
618 #define yyerrok (yyerrstatus = 0)
619 #define yyclearin (yychar = YYEMPTY)
620 #define YYEMPTY (-2)
621 #define YYEOF 0
623 #define YYACCEPT goto yyacceptlab
624 #define YYABORT goto yyabortlab
625 #define YYERROR goto yyerrorlab
628 /* Like YYERROR except do call yyerror. This remains here temporarily
629 to ease the transition to the new meaning of YYERROR, for GCC.
630 Once GCC version 2 has supplanted version 1, this can go. */
632 #define YYFAIL goto yyerrlab
634 #define YYRECOVERING() (!!yyerrstatus)
636 #define YYBACKUP(Token, Value) \
637 do \
638 if (yychar == YYEMPTY && yylen == 1) \
640 yychar = (Token); \
641 yylval = (Value); \
642 yytoken = YYTRANSLATE (yychar); \
643 YYPOPSTACK; \
644 goto yybackup; \
646 else \
648 yyerror (YY_("syntax error: cannot back up")); \
649 YYERROR; \
651 while (0)
654 #define YYTERROR 1
655 #define YYERRCODE 256
658 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
659 If N is 0, then set CURRENT to the empty location which ends
660 the previous symbol: RHS[0] (always defined). */
662 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
663 #ifndef YYLLOC_DEFAULT
664 # define YYLLOC_DEFAULT(Current, Rhs, N) \
665 do \
666 if (N) \
668 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
669 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
670 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
671 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
673 else \
675 (Current).first_line = (Current).last_line = \
676 YYRHSLOC (Rhs, 0).last_line; \
677 (Current).first_column = (Current).last_column = \
678 YYRHSLOC (Rhs, 0).last_column; \
680 while (0)
681 #endif
684 /* YY_LOCATION_PRINT -- Print the location on the stream.
685 This macro was not mandated originally: define only if we know
686 we won't break user code: when these are the locations we know. */
688 #ifndef YY_LOCATION_PRINT
689 # if YYLTYPE_IS_TRIVIAL
690 # define YY_LOCATION_PRINT(File, Loc) \
691 fprintf (File, "%d.%d-%d.%d", \
692 (Loc).first_line, (Loc).first_column, \
693 (Loc).last_line, (Loc).last_column)
694 # else
695 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
696 # endif
697 #endif
700 /* YYLEX -- calling `yylex' with the right arguments. */
702 #ifdef YYLEX_PARAM
703 # define YYLEX yylex (YYLEX_PARAM)
704 #else
705 # define YYLEX yylex ()
706 #endif
708 /* Enable debugging if requested. */
709 #if YYDEBUG
711 # ifndef YYFPRINTF
712 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
713 # define YYFPRINTF fprintf
714 # endif
716 # define YYDPRINTF(Args) \
717 do { \
718 if (yydebug) \
719 YYFPRINTF Args; \
720 } while (0)
722 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
723 do { \
724 if (yydebug) \
726 YYFPRINTF (stderr, "%s ", Title); \
727 yysymprint (stderr, \
728 Type, Value); \
729 YYFPRINTF (stderr, "\n"); \
731 } while (0)
733 /*------------------------------------------------------------------.
734 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
735 | TOP (included). |
736 `------------------------------------------------------------------*/
738 #if defined (__STDC__) || defined (__cplusplus)
739 static void
740 yy_stack_print (short int *bottom, short int *top)
741 #else
742 static void
743 yy_stack_print (bottom, top)
744 short int *bottom;
745 short int *top;
746 #endif
748 YYFPRINTF (stderr, "Stack now");
749 for (/* Nothing. */; bottom <= top; ++bottom)
750 YYFPRINTF (stderr, " %d", *bottom);
751 YYFPRINTF (stderr, "\n");
754 # define YY_STACK_PRINT(Bottom, Top) \
755 do { \
756 if (yydebug) \
757 yy_stack_print ((Bottom), (Top)); \
758 } while (0)
761 /*------------------------------------------------.
762 | Report that the YYRULE is going to be reduced. |
763 `------------------------------------------------*/
765 #if defined (__STDC__) || defined (__cplusplus)
766 static void
767 yy_reduce_print (int yyrule)
768 #else
769 static void
770 yy_reduce_print (yyrule)
771 int yyrule;
772 #endif
774 int yyi;
775 unsigned long int yylno = yyrline[yyrule];
776 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
777 yyrule - 1, yylno);
778 /* Print the symbols being reduced, and their result. */
779 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
780 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
781 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
784 # define YY_REDUCE_PRINT(Rule) \
785 do { \
786 if (yydebug) \
787 yy_reduce_print (Rule); \
788 } while (0)
790 /* Nonzero means print parse trace. It is left uninitialized so that
791 multiple parsers can coexist. */
792 int yydebug;
793 #else /* !YYDEBUG */
794 # define YYDPRINTF(Args)
795 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
796 # define YY_STACK_PRINT(Bottom, Top)
797 # define YY_REDUCE_PRINT(Rule)
798 #endif /* !YYDEBUG */
801 /* YYINITDEPTH -- initial size of the parser's stacks. */
802 #ifndef YYINITDEPTH
803 # define YYINITDEPTH 200
804 #endif
806 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
807 if the built-in stack extension method is used).
809 Do not make this value too large; the results are undefined if
810 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
811 evaluated with infinite-precision integer arithmetic. */
813 #ifndef YYMAXDEPTH
814 # define YYMAXDEPTH 10000
815 #endif
819 #if YYERROR_VERBOSE
821 # ifndef yystrlen
822 # if defined (__GLIBC__) && defined (_STRING_H)
823 # define yystrlen strlen
824 # else
825 /* Return the length of YYSTR. */
826 static YYSIZE_T
827 # if defined (__STDC__) || defined (__cplusplus)
828 yystrlen (const char *yystr)
829 # else
830 yystrlen (yystr)
831 const char *yystr;
832 # endif
834 const char *yys = yystr;
836 while (*yys++ != '\0')
837 continue;
839 return yys - yystr - 1;
841 # endif
842 # endif
844 # ifndef yystpcpy
845 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
846 # define yystpcpy stpcpy
847 # else
848 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
849 YYDEST. */
850 static char *
851 # if defined (__STDC__) || defined (__cplusplus)
852 yystpcpy (char *yydest, const char *yysrc)
853 # else
854 yystpcpy (yydest, yysrc)
855 char *yydest;
856 const char *yysrc;
857 # endif
859 char *yyd = yydest;
860 const char *yys = yysrc;
862 while ((*yyd++ = *yys++) != '\0')
863 continue;
865 return yyd - 1;
867 # endif
868 # endif
870 # ifndef yytnamerr
871 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
872 quotes and backslashes, so that it's suitable for yyerror. The
873 heuristic is that double-quoting is unnecessary unless the string
874 contains an apostrophe, a comma, or backslash (other than
875 backslash-backslash). YYSTR is taken from yytname. If YYRES is
876 null, do not copy; instead, return the length of what the result
877 would have been. */
878 static YYSIZE_T
879 yytnamerr (char *yyres, const char *yystr)
881 if (*yystr == '"')
883 size_t yyn = 0;
884 char const *yyp = yystr;
886 for (;;)
887 switch (*++yyp)
889 case '\'':
890 case ',':
891 goto do_not_strip_quotes;
893 case '\\':
894 if (*++yyp != '\\')
895 goto do_not_strip_quotes;
896 /* Fall through. */
897 default:
898 if (yyres)
899 yyres[yyn] = *yyp;
900 yyn++;
901 break;
903 case '"':
904 if (yyres)
905 yyres[yyn] = '\0';
906 return yyn;
908 do_not_strip_quotes: ;
911 if (! yyres)
912 return yystrlen (yystr);
914 return yystpcpy (yyres, yystr) - yyres;
916 # endif
918 #endif /* YYERROR_VERBOSE */
922 #if YYDEBUG
923 /*--------------------------------.
924 | Print this symbol on YYOUTPUT. |
925 `--------------------------------*/
927 #if defined (__STDC__) || defined (__cplusplus)
928 static void
929 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
930 #else
931 static void
932 yysymprint (yyoutput, yytype, yyvaluep)
933 FILE *yyoutput;
934 int yytype;
935 YYSTYPE *yyvaluep;
936 #endif
938 /* Pacify ``unused variable'' warnings. */
939 (void) yyvaluep;
941 if (yytype < YYNTOKENS)
942 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
943 else
944 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
947 # ifdef YYPRINT
948 if (yytype < YYNTOKENS)
949 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
950 # endif
951 switch (yytype)
953 default:
954 break;
956 YYFPRINTF (yyoutput, ")");
959 #endif /* ! YYDEBUG */
960 /*-----------------------------------------------.
961 | Release the memory associated to this symbol. |
962 `-----------------------------------------------*/
964 #if defined (__STDC__) || defined (__cplusplus)
965 static void
966 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
967 #else
968 static void
969 yydestruct (yymsg, yytype, yyvaluep)
970 const char *yymsg;
971 int yytype;
972 YYSTYPE *yyvaluep;
973 #endif
975 /* Pacify ``unused variable'' warnings. */
976 (void) yyvaluep;
978 if (!yymsg)
979 yymsg = "Deleting";
980 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
982 switch (yytype)
985 default:
986 break;
991 /* Prevent warnings from -Wmissing-prototypes. */
993 #ifdef YYPARSE_PARAM
994 # if defined (__STDC__) || defined (__cplusplus)
995 int yyparse (void *YYPARSE_PARAM);
996 # else
997 int yyparse ();
998 # endif
999 #else /* ! YYPARSE_PARAM */
1000 #if defined (__STDC__) || defined (__cplusplus)
1001 int yyparse (void);
1002 #else
1003 int yyparse ();
1004 #endif
1005 #endif /* ! YYPARSE_PARAM */
1009 /* The look-ahead symbol. */
1010 int yychar;
1012 /* The semantic value of the look-ahead symbol. */
1013 YYSTYPE yylval;
1015 /* Number of syntax errors so far. */
1016 int yynerrs;
1020 /*----------.
1021 | yyparse. |
1022 `----------*/
1024 #ifdef YYPARSE_PARAM
1025 # if defined (__STDC__) || defined (__cplusplus)
1026 int yyparse (void *YYPARSE_PARAM)
1027 # else
1028 int yyparse (YYPARSE_PARAM)
1029 void *YYPARSE_PARAM;
1030 # endif
1031 #else /* ! YYPARSE_PARAM */
1032 #if defined (__STDC__) || defined (__cplusplus)
1034 yyparse (void)
1035 #else
1037 yyparse ()
1038 #endif
1039 #endif
1041 int yystate;
1042 int yyn;
1043 int yyresult;
1044 /* Number of tokens to shift before error messages enabled. */
1045 int yyerrstatus;
1046 /* Look-ahead token as an internal (translated) token number. */
1047 int yytoken = 0;
1049 /* Three stacks and their tools:
1050 `yyss': related to states,
1051 `yyvs': related to semantic values,
1052 `yyls': related to locations.
1054 Refer to the stacks thru separate pointers, to allow yyoverflow
1055 to reallocate them elsewhere. */
1057 /* The state stack. */
1058 short int yyssa[YYINITDEPTH];
1059 short int *yyss = yyssa;
1060 short int *yyssp;
1062 /* The semantic value stack. */
1063 YYSTYPE yyvsa[YYINITDEPTH];
1064 YYSTYPE *yyvs = yyvsa;
1065 YYSTYPE *yyvsp;
1069 #define YYPOPSTACK (yyvsp--, yyssp--)
1071 YYSIZE_T yystacksize = YYINITDEPTH;
1073 /* The variables used to return semantic value and location from the
1074 action routines. */
1075 YYSTYPE yyval;
1078 /* When reducing, the number of symbols on the RHS of the reduced
1079 rule. */
1080 int yylen;
1082 YYDPRINTF ((stderr, "Starting parse\n"));
1084 yystate = 0;
1085 yyerrstatus = 0;
1086 yynerrs = 0;
1087 yychar = YYEMPTY; /* Cause a token to be read. */
1089 /* Initialize stack pointers.
1090 Waste one element of value and location stack
1091 so that they stay on the same level as the state stack.
1092 The wasted elements are never initialized. */
1094 yyssp = yyss;
1095 yyvsp = yyvs;
1097 goto yysetstate;
1099 /*------------------------------------------------------------.
1100 | yynewstate -- Push a new state, which is found in yystate. |
1101 `------------------------------------------------------------*/
1102 yynewstate:
1103 /* In all cases, when you get here, the value and location stacks
1104 have just been pushed. so pushing a state here evens the stacks.
1106 yyssp++;
1108 yysetstate:
1109 *yyssp = yystate;
1111 if (yyss + yystacksize - 1 <= yyssp)
1113 /* Get the current used size of the three stacks, in elements. */
1114 YYSIZE_T yysize = yyssp - yyss + 1;
1116 #ifdef yyoverflow
1118 /* Give user a chance to reallocate the stack. Use copies of
1119 these so that the &'s don't force the real ones into
1120 memory. */
1121 YYSTYPE *yyvs1 = yyvs;
1122 short int *yyss1 = yyss;
1125 /* Each stack pointer address is followed by the size of the
1126 data in use in that stack, in bytes. This used to be a
1127 conditional around just the two extra args, but that might
1128 be undefined if yyoverflow is a macro. */
1129 yyoverflow (YY_("memory exhausted"),
1130 &yyss1, yysize * sizeof (*yyssp),
1131 &yyvs1, yysize * sizeof (*yyvsp),
1133 &yystacksize);
1135 yyss = yyss1;
1136 yyvs = yyvs1;
1138 #else /* no yyoverflow */
1139 # ifndef YYSTACK_RELOCATE
1140 goto yyexhaustedlab;
1141 # else
1142 /* Extend the stack our own way. */
1143 if (YYMAXDEPTH <= yystacksize)
1144 goto yyexhaustedlab;
1145 yystacksize *= 2;
1146 if (YYMAXDEPTH < yystacksize)
1147 yystacksize = YYMAXDEPTH;
1150 short int *yyss1 = yyss;
1151 union yyalloc *yyptr =
1152 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1153 if (! yyptr)
1154 goto yyexhaustedlab;
1155 YYSTACK_RELOCATE (yyss);
1156 YYSTACK_RELOCATE (yyvs);
1158 # undef YYSTACK_RELOCATE
1159 if (yyss1 != yyssa)
1160 YYSTACK_FREE (yyss1);
1162 # endif
1163 #endif /* no yyoverflow */
1165 yyssp = yyss + yysize - 1;
1166 yyvsp = yyvs + yysize - 1;
1169 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1170 (unsigned long int) yystacksize));
1172 if (yyss + yystacksize - 1 <= yyssp)
1173 YYABORT;
1176 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1178 goto yybackup;
1180 /*-----------.
1181 | yybackup. |
1182 `-----------*/
1183 yybackup:
1185 /* Do appropriate processing given the current state. */
1186 /* Read a look-ahead token if we need one and don't already have one. */
1187 /* yyresume: */
1189 /* First try to decide what to do without reference to look-ahead token. */
1191 yyn = yypact[yystate];
1192 if (yyn == YYPACT_NINF)
1193 goto yydefault;
1195 /* Not known => get a look-ahead token if don't already have one. */
1197 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1198 if (yychar == YYEMPTY)
1200 YYDPRINTF ((stderr, "Reading a token: "));
1201 yychar = YYLEX;
1204 if (yychar <= YYEOF)
1206 yychar = yytoken = YYEOF;
1207 YYDPRINTF ((stderr, "Now at end of input.\n"));
1209 else
1211 yytoken = YYTRANSLATE (yychar);
1212 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1215 /* If the proper action on seeing token YYTOKEN is to reduce or to
1216 detect an error, take that action. */
1217 yyn += yytoken;
1218 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1219 goto yydefault;
1220 yyn = yytable[yyn];
1221 if (yyn <= 0)
1223 if (yyn == 0 || yyn == YYTABLE_NINF)
1224 goto yyerrlab;
1225 yyn = -yyn;
1226 goto yyreduce;
1229 if (yyn == YYFINAL)
1230 YYACCEPT;
1232 /* Shift the look-ahead token. */
1233 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1235 /* Discard the token being shifted unless it is eof. */
1236 if (yychar != YYEOF)
1237 yychar = YYEMPTY;
1239 *++yyvsp = yylval;
1242 /* Count tokens shifted since error; after three, turn off error
1243 status. */
1244 if (yyerrstatus)
1245 yyerrstatus--;
1247 yystate = yyn;
1248 goto yynewstate;
1251 /*-----------------------------------------------------------.
1252 | yydefault -- do the default action for the current state. |
1253 `-----------------------------------------------------------*/
1254 yydefault:
1255 yyn = yydefact[yystate];
1256 if (yyn == 0)
1257 goto yyerrlab;
1258 goto yyreduce;
1261 /*-----------------------------.
1262 | yyreduce -- Do a reduction. |
1263 `-----------------------------*/
1264 yyreduce:
1265 /* yyn is the number of a rule to reduce with. */
1266 yylen = yyr2[yyn];
1268 /* If YYLEN is nonzero, implement the default value of the action:
1269 `$$ = $1'.
1271 Otherwise, the following line sets YYVAL to garbage.
1272 This behavior is undocumented and Bison
1273 users should not rely upon it. Assigning to YYVAL
1274 unconditionally makes the parser a bit smaller, and it avoids a
1275 GCC warning that YYVAL may be used uninitialized. */
1276 yyval = yyvsp[1-yylen];
1279 YY_REDUCE_PRINT (yyn);
1280 switch (yyn)
1282 case 7:
1283 #line 91 "find_dep.y"
1285 if (strcasecmp((yyvsp[-1].string), "interface") == 0)
1286 in_interface = true;
1287 free((yyvsp[-1].string));
1289 break;
1291 case 8:
1292 #line 96 "find_dep.y"
1294 if (strcasecmp((yyvsp[-3].string), "use") == 0) {
1295 if (!pp_ignore) {
1296 DEBUG_PRINT("Use '%s'\n", (yyvsp[-2].string));
1297 if (!list_find(options.ignore_mods, (yyvsp[-2].string),COMP_FUN(&strcasecmp))) {
1298 if (!list_find(dep->modules, (yyvsp[-2].string), COMP_FUN(&strcasecmp)))
1299 dep->modules = list_prepend(dep->modules, (yyvsp[-2].string));
1302 } else if (strcasecmp((yyvsp[-3].string), "module") == 0) {
1303 if (!pp_ignore && !in_interface) {
1304 if (!list_find(options.ignore_mods, (yyvsp[-2].string),COMP_FUN(&strcasecmp))) {
1305 Module *mod;
1307 mod = module_new();
1308 mod->sourcefile = xstrdup(sourcefile);
1309 mod->modulename = (yyvsp[-2].string);
1310 mod->modfile_name = modfile_name((yyvsp[-2].string), mod->sourcefile);
1312 if (list_find(modules, mod, &modcmp))
1313 warning("Several modules named '%s'", (yyvsp[-2].string));
1314 else
1315 modules = list_prepend(modules, mod);
1317 if (!list_find(dep->targets, mod->modfile_name,
1318 COMP_FUN(&strcasecmp)))
1319 dep->targets=list_prepend(dep->targets, mod->modfile_name);
1322 } else if (strcasecmp((yyvsp[-3].string), "interface") == 0) {
1323 in_interface = true;
1324 free((yyvsp[-2].string));
1325 } else if (strcasecmp((yyvsp[-2].string), "interface") == 0
1326 && strcasecmp((yyvsp[-3].string), "end") == 0) {
1327 in_interface = false;
1328 free((yyvsp[-2].string));
1331 free((yyvsp[-3].string));
1333 break;
1335 case 9:
1336 #line 136 "find_dep.y"
1338 if (strcasecmp((yyvsp[-3].string), "include") == 0) {
1339 handle_include((yyvsp[-2].string));
1341 free((yyvsp[-3].string));
1342 free((yyvsp[-2].string));
1344 break;
1346 case 10:
1347 #line 143 "find_dep.y"
1349 handle_include((yyvsp[-2].string));
1350 free((yyvsp[-2].string));
1352 break;
1354 case 12:
1355 #line 148 "find_dep.y"
1357 if (!pp_ignore) {
1358 DEBUG_PRINT("%s defined\n", (yyvsp[-2].string));
1359 defmac = macro_new();
1360 macro_setname(defmac, (yyvsp[-2].string));
1361 if (!list_find(macrolist, defmac, &macrocmp))
1362 macrolist = list_prepend(macrolist, defmac);
1365 break;
1367 case 13:
1368 #line 157 "find_dep.y"
1370 if (!pp_ignore) {
1371 Macro *mac;
1372 List *l;
1374 mac = macro_new();
1375 macro_setname(mac, (yyvsp[-2].string));
1377 l = list_find(macrolist, mac, &macrocmp);
1378 if (l) {
1379 macrolist = list_remove(macrolist, l);
1380 macro_free(l->data);
1381 list_free(l);
1383 macro_free(mac);
1386 break;
1388 case 14:
1389 #line 174 "find_dep.y"
1391 Macro *mac;
1393 mac = macro_new();
1394 macro_setname(mac, (yyvsp[-2].string));
1396 skip_i++;
1397 if (pp_ignore)
1398 pp_ignore++;
1399 else if (!list_find(macrolist, mac, &macrocmp))
1400 pp_ignore = 1;
1401 else
1402 skip_to_end[skip_i] = true;
1404 macro_free(mac);
1406 break;
1408 case 15:
1409 #line 190 "find_dep.y"
1411 Macro *mac;
1413 mac = macro_new();
1414 macro_setname(mac, (yyvsp[-2].string));
1416 skip_i++;
1417 if (pp_ignore)
1418 pp_ignore++;
1419 if (list_find(macrolist, mac, &macrocmp))
1420 pp_ignore = 1;
1421 else
1422 skip_to_end[skip_i] = true;
1424 macro_free(mac);
1426 break;
1428 case 16:
1429 #line 206 "find_dep.y"
1431 /* #if:s can't be completely ignored, since #else:s, #elif:s and
1432 * #endif:s aren't. An #if branch is allways taken, and so are any
1433 * following #else or #elif:s (ie. no 'skip_to_end'). */
1434 skip_i++;
1435 if (pp_ignore) pp_ignore++;
1436 skip_to_end[skip_i] = false;
1438 break;
1440 case 17:
1441 #line 214 "find_dep.y"
1443 /* Allways taken unless an #ifdef or #ifndef-branch has been taken
1444 * allready. */
1445 if (skip_to_end[skip_i] && pp_ignore == 0) pp_ignore = 1;
1447 break;
1449 case 18:
1450 #line 219 "find_dep.y"
1452 if (pp_ignore == 1 && skip_to_end[skip_i] == false)
1453 pp_ignore = 0;
1454 else if (pp_ignore == 0)
1455 pp_ignore = 1;
1457 break;
1459 case 19:
1460 #line 225 "find_dep.y"
1462 skip_to_end[skip_i] = false;
1463 if (skip_i > 0) skip_i--;
1464 if (pp_ignore) pp_ignore--;
1466 break;
1468 case 23:
1469 #line 233 "find_dep.y"
1470 { yyerrok; }
1471 break;
1473 case 45:
1474 #line 277 "find_dep.y"
1475 { free ((yyvsp[0].string)); }
1476 break;
1478 case 46:
1479 #line 278 "find_dep.y"
1480 { free ((yyvsp[0].string)); }
1481 break;
1483 case 49:
1484 #line 281 "find_dep.y"
1486 if (options.warn_confused)
1487 warning ("Unterminated string in file '%s' on line %i",
1488 curr_file, (yyvsp[0].number));
1490 break;
1493 default: break;
1496 /* Line 1126 of yacc.c. */
1497 #line 1500 "y.tab.c"
1499 yyvsp -= yylen;
1500 yyssp -= yylen;
1503 YY_STACK_PRINT (yyss, yyssp);
1505 *++yyvsp = yyval;
1508 /* Now `shift' the result of the reduction. Determine what state
1509 that goes to, based on the state we popped back to and the rule
1510 number reduced by. */
1512 yyn = yyr1[yyn];
1514 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1515 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1516 yystate = yytable[yystate];
1517 else
1518 yystate = yydefgoto[yyn - YYNTOKENS];
1520 goto yynewstate;
1523 /*------------------------------------.
1524 | yyerrlab -- here on detecting error |
1525 `------------------------------------*/
1526 yyerrlab:
1527 /* If not already recovering from an error, report this error. */
1528 if (!yyerrstatus)
1530 ++yynerrs;
1531 #if YYERROR_VERBOSE
1532 yyn = yypact[yystate];
1534 if (YYPACT_NINF < yyn && yyn < YYLAST)
1536 int yytype = YYTRANSLATE (yychar);
1537 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1538 YYSIZE_T yysize = yysize0;
1539 YYSIZE_T yysize1;
1540 int yysize_overflow = 0;
1541 char *yymsg = 0;
1542 # define YYERROR_VERBOSE_ARGS_MAXIMUM 5
1543 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1544 int yyx;
1546 #if 0
1547 /* This is so xgettext sees the translatable formats that are
1548 constructed on the fly. */
1549 YY_("syntax error, unexpected %s");
1550 YY_("syntax error, unexpected %s, expecting %s");
1551 YY_("syntax error, unexpected %s, expecting %s or %s");
1552 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1553 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1554 #endif
1555 char *yyfmt;
1556 char const *yyf;
1557 static char const yyunexpected[] = "syntax error, unexpected %s";
1558 static char const yyexpecting[] = ", expecting %s";
1559 static char const yyor[] = " or %s";
1560 char yyformat[sizeof yyunexpected
1561 + sizeof yyexpecting - 1
1562 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1563 * (sizeof yyor - 1))];
1564 char const *yyprefix = yyexpecting;
1566 /* Start YYX at -YYN if negative to avoid negative indexes in
1567 YYCHECK. */
1568 int yyxbegin = yyn < 0 ? -yyn : 0;
1570 /* Stay within bounds of both yycheck and yytname. */
1571 int yychecklim = YYLAST - yyn;
1572 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1573 int yycount = 1;
1575 yyarg[0] = yytname[yytype];
1576 yyfmt = yystpcpy (yyformat, yyunexpected);
1578 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1579 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1581 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1583 yycount = 1;
1584 yysize = yysize0;
1585 yyformat[sizeof yyunexpected - 1] = '\0';
1586 break;
1588 yyarg[yycount++] = yytname[yyx];
1589 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1590 yysize_overflow |= yysize1 < yysize;
1591 yysize = yysize1;
1592 yyfmt = yystpcpy (yyfmt, yyprefix);
1593 yyprefix = yyor;
1596 yyf = YY_(yyformat);
1597 yysize1 = yysize + yystrlen (yyf);
1598 yysize_overflow |= yysize1 < yysize;
1599 yysize = yysize1;
1601 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
1602 yymsg = (char *) YYSTACK_ALLOC (yysize);
1603 if (yymsg)
1605 /* Avoid sprintf, as that infringes on the user's name space.
1606 Don't have undefined behavior even if the translation
1607 produced a string with the wrong number of "%s"s. */
1608 char *yyp = yymsg;
1609 int yyi = 0;
1610 while ((*yyp = *yyf))
1612 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1614 yyp += yytnamerr (yyp, yyarg[yyi++]);
1615 yyf += 2;
1617 else
1619 yyp++;
1620 yyf++;
1623 yyerror (yymsg);
1624 YYSTACK_FREE (yymsg);
1626 else
1628 yyerror (YY_("syntax error"));
1629 goto yyexhaustedlab;
1632 else
1633 #endif /* YYERROR_VERBOSE */
1634 yyerror (YY_("syntax error"));
1639 if (yyerrstatus == 3)
1641 /* If just tried and failed to reuse look-ahead token after an
1642 error, discard it. */
1644 if (yychar <= YYEOF)
1646 /* Return failure if at end of input. */
1647 if (yychar == YYEOF)
1648 YYABORT;
1650 else
1652 yydestruct ("Error: discarding", yytoken, &yylval);
1653 yychar = YYEMPTY;
1657 /* Else will try to reuse look-ahead token after shifting the error
1658 token. */
1659 goto yyerrlab1;
1662 /*---------------------------------------------------.
1663 | yyerrorlab -- error raised explicitly by YYERROR. |
1664 `---------------------------------------------------*/
1665 yyerrorlab:
1667 /* Pacify compilers like GCC when the user code never invokes
1668 YYERROR and the label yyerrorlab therefore never appears in user
1669 code. */
1670 if (0)
1671 goto yyerrorlab;
1673 yyvsp -= yylen;
1674 yyssp -= yylen;
1675 yystate = *yyssp;
1676 goto yyerrlab1;
1679 /*-------------------------------------------------------------.
1680 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1681 `-------------------------------------------------------------*/
1682 yyerrlab1:
1683 yyerrstatus = 3; /* Each real token shifted decrements this. */
1685 for (;;)
1687 yyn = yypact[yystate];
1688 if (yyn != YYPACT_NINF)
1690 yyn += YYTERROR;
1691 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1693 yyn = yytable[yyn];
1694 if (0 < yyn)
1695 break;
1699 /* Pop the current state because it cannot handle the error token. */
1700 if (yyssp == yyss)
1701 YYABORT;
1704 yydestruct ("Error: popping", yystos[yystate], yyvsp);
1705 YYPOPSTACK;
1706 yystate = *yyssp;
1707 YY_STACK_PRINT (yyss, yyssp);
1710 if (yyn == YYFINAL)
1711 YYACCEPT;
1713 *++yyvsp = yylval;
1716 /* Shift the error token. */
1717 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1719 yystate = yyn;
1720 goto yynewstate;
1723 /*-------------------------------------.
1724 | yyacceptlab -- YYACCEPT comes here. |
1725 `-------------------------------------*/
1726 yyacceptlab:
1727 yyresult = 0;
1728 goto yyreturn;
1730 /*-----------------------------------.
1731 | yyabortlab -- YYABORT comes here. |
1732 `-----------------------------------*/
1733 yyabortlab:
1734 yyresult = 1;
1735 goto yyreturn;
1737 #ifndef yyoverflow
1738 /*-------------------------------------------------.
1739 | yyexhaustedlab -- memory exhaustion comes here. |
1740 `-------------------------------------------------*/
1741 yyexhaustedlab:
1742 yyerror (YY_("memory exhausted"));
1743 yyresult = 2;
1744 /* Fall through. */
1745 #endif
1747 yyreturn:
1748 if (yychar != YYEOF && yychar != YYEMPTY)
1749 yydestruct ("Cleanup: discarding lookahead",
1750 yytoken, &yylval);
1751 while (yyssp != yyss)
1753 yydestruct ("Cleanup: popping",
1754 yystos[*yyssp], yyvsp);
1755 YYPOPSTACK;
1757 #ifndef yyoverflow
1758 if (yyss != yyssa)
1759 YYSTACK_FREE (yyss);
1760 #endif
1761 return yyresult;
1765 #line 288 "find_dep.y"
1768 int yyerror(const char *s)
1770 extern int yylineno;
1772 if (options.warn_confused)
1773 warning("Line %i in file '%s' confuses me\n", yylineno, curr_file);
1775 return 0;
1779 /* Return false for failure reading file, else return true. */
1781 bool find_dep(char *file, Dependency *d, List **mods, const List *predef_macro)
1783 extern FILE *yyin;
1784 extern int yylineno;
1785 Macro *mac;
1786 const List *h;
1788 /* Initialize */
1789 sourcefile = file;
1790 curr_file = file;
1791 dep = d;
1792 modules = *mods;
1793 yylineno = 1;
1794 filestack_i = 0;
1795 pp_ignore = 0;
1797 yyin = open_src_file(file, options.src_path);
1798 if (yyin == NULL) {
1799 warning("Skipping file '%s': %s", file, strerror(errno));
1800 return false;
1803 /* Check source format */
1804 if (options.src_fmt == SUFFIX)
1805 lex_set_format(get_format(file));
1806 else
1807 lex_set_format(options.src_fmt);
1809 /* Initialize a list of macros, and fill it with macrodefinitions from -D
1810 * flags at the command line */
1811 macrolist = NULL;
1812 for (h = predef_macro; h; h = h->next) {
1813 mac = macro_new();
1814 macro_copy(mac, (Macro *)h->data);
1815 if (!list_find(macrolist, mac, &macrocmp))
1816 macrolist = list_prepend(macrolist, mac);
1819 yyparse();
1820 *mods = modules;
1822 /* Delete macrolist */
1823 for (h = macrolist; h; h = h->next)
1824 macro_free((Macro *)h->data);
1825 list_free(macrolist);
1827 fclose(yyin);
1829 return true;
1833 int modstrcmp(const void *s, const void *m)
1835 return strcasecmp(((Module *)m)->modulename, (char *)s);
1840 static int modcmp (const void *m1, const void *m2)
1842 return strcasecmp(((Module *)m1)->modulename, ((Module *)m2)->modulename);
1847 static char *fixed_suffixes[] = {".f", ".F", ".for", ".FOR", ".ftn", ".FTN"};
1849 static char *free_suffixes[] = {".f90", ".F90", ".f95", ".F95"};
1851 static const int fixsuffn = sizeof(fixed_suffixes)/sizeof(void *);
1852 static const int freesuffn = sizeof(free_suffixes)/sizeof(void *);
1855 SourceFmt get_format(const char *filename)
1857 const char *p;
1858 int i;
1860 /* Search for the end */
1861 for (p = filename; *p; p++);
1863 /* Search backwards for the last '.' */
1864 for (; *p != '.' && p != filename; p--);
1866 /* Check for any of the free suffixes */
1867 for (i = 0; i < freesuffn; i++)
1868 if (strcmp(p, free_suffixes[i]) == 0) return FREE;
1870 /* Check for any of the fixed suffixes */
1871 for (i = 0; i < fixsuffn; i++)
1872 if (strcmp(p, fixed_suffixes[i]) == 0) return FIXED;
1874 return UNKNOWN;
1878 void pop_filestack()
1880 curr_file = filestack[--filestack_i];
1884 void handle_include(const char *incfile)
1886 if (!pp_ignore) {
1887 filestack[filestack_i++] = curr_file;
1888 curr_file = remove_citation(incfile);
1889 if (lex_include_file(curr_file)) {
1890 DEBUG_PRINT("including file '%s'\n", curr_file);
1891 if (!list_find(dep->includes, curr_file, COMP_FUN(&strcasecmp)))
1892 dep->includes = list_prepend(dep->includes, curr_file);
1893 } else {
1894 pop_filestack();
1900 Module *module_new()
1902 Module *m;
1904 m = (Module *) xmalloc(sizeof(Module));
1905 m->modulename = m->modfile_name = m->sourcefile = NULL;
1906 return m;
1910 Dependency *dependency_new()
1912 Dependency *d;
1914 d = (Dependency *) xmalloc(sizeof(Dependency));
1915 d->sourcefile = NULL;
1916 d->targets = d->modules = d->includes = NULL;
1917 return d;