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)
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. */
40 #define YYBISON_VERSION "2.1"
43 #define YYSKELETON_NAME "yacc.c"
48 /* Using locations. */
49 #define YYLSP_NEEDED 0
56 /* Put the tokens into the symbol table, so that GDB and other debuggers
82 UNTERMINATED_STRING
= 281,
89 #define ASSIGNMENT_OP 259
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
99 #define CPP_IFNDEF 269
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
118 /* Copy the first part of user declarations. */
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
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
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
152 #include "errormesg.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];
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
);
177 /* Defined in lexer.l */
179 bool lex_include_file(const char *incfile
);
180 void lex_set_format(SourceFmt fmt
);
184 /* Enabling traces. */
189 /* Enabling verbose error messages. */
190 #ifdef YYERROR_VERBOSE
191 # undef YYERROR_VERBOSE
192 # define YYERROR_VERBOSE 1
194 # define YYERROR_VERBOSE 0
197 /* Enabling the token table. */
198 #ifndef YYTOKEN_TABLE
199 # define YYTOKEN_TABLE 0
202 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
203 #line 65 "find_dep.y"
204 typedef union YYSTYPE
{
208 /* Line 196 of yacc.c. */
210 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
211 # define YYSTYPE_IS_DECLARED 1
212 # define YYSTYPE_IS_TRIVIAL 1
217 /* Copy the second part of user declarations. */
220 /* Line 219 of yacc.c. */
223 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
224 # define YYSIZE_T __SIZE_TYPE__
226 #if ! defined (YYSIZE_T) && defined (size_t)
227 # define YYSIZE_T size_t
229 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
230 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
231 # define YYSIZE_T size_t
233 #if ! defined (YYSIZE_T)
234 # define YYSIZE_T unsigned int
240 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
241 # define YY_(msgid) dgettext ("bison-runtime", msgid)
245 # define YY_(msgid) msgid
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
256 # define YYSTACK_ALLOC __builtin_alloca
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
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 */
278 # define YYSTACK_ALLOC YYMALLOC
279 # define YYSTACK_FREE YYFREE
280 # ifndef YYSTACK_ALLOC_MAXIMUM
281 # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
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 */
295 # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
296 && (defined (__STDC__) || defined (__cplusplus)))
297 void free (void *); /* INFRINGES ON USER NAME SPACE */
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. */
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
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
330 # if defined (__GNUC__) && 1 < __GNUC__
331 # define YYCOPY(To, From, Count) \
332 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
334 # define YYCOPY(To, From, Count) \
338 for (yyi = 0; yyi < (Count); yyi++) \
339 (To)[yyi] = (From)[yyi]; \
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
350 # define YYSTACK_RELOCATE(Stack) \
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); \
363 #if defined (__STDC__) || defined (__cplusplus)
364 typedef signed char yysigned_char
;
366 typedef short int yysigned_char
;
369 /* YYFINAL -- State number of the termination state. */
371 /* YYLAST -- Last index in YYTABLE. */
374 /* YYNTOKENS -- Number of terminals. */
376 /* YYNNTS -- Number of nonterminals. */
378 /* YYNRULES -- Number of rules. */
380 /* YYNRULES -- Number of states. */
383 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
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,
425 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
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
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
484 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
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
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,
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
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,
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,
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,
618 #define yyerrok (yyerrstatus = 0)
619 #define yyclearin (yychar = YYEMPTY)
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) \
638 if (yychar == YYEMPTY && yylen == 1) \
642 yytoken = YYTRANSLATE (yychar); \
648 yyerror (YY_("syntax error: cannot back up")); \
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) \
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; \
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; \
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)
695 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
700 /* YYLEX -- calling `yylex' with the right arguments. */
703 # define YYLEX yylex (YYLEX_PARAM)
705 # define YYLEX yylex ()
708 /* Enable debugging if requested. */
712 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
713 # define YYFPRINTF fprintf
716 # define YYDPRINTF(Args) \
722 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
726 YYFPRINTF (stderr, "%s ", Title); \
727 yysymprint (stderr, \
729 YYFPRINTF (stderr, "\n"); \
733 /*------------------------------------------------------------------.
734 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
736 `------------------------------------------------------------------*/
738 #if defined (__STDC__) || defined (__cplusplus)
740 yy_stack_print (short int *bottom
, short int *top
)
743 yy_stack_print (bottom
, top
)
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) \
757 yy_stack_print ((Bottom), (Top)); \
761 /*------------------------------------------------.
762 | Report that the YYRULE is going to be reduced. |
763 `------------------------------------------------*/
765 #if defined (__STDC__) || defined (__cplusplus)
767 yy_reduce_print (int yyrule
)
770 yy_reduce_print (yyrule
)
775 unsigned long int yylno
= yyrline
[yyrule
];
776 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu), ",
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) \
787 yy_reduce_print (Rule); \
790 /* Nonzero means print parse trace. It is left uninitialized so that
791 multiple parsers can coexist. */
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. */
803 # define YYINITDEPTH 200
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. */
814 # define YYMAXDEPTH 10000
822 # if defined (__GLIBC__) && defined (_STRING_H)
823 # define yystrlen strlen
825 /* Return the length of YYSTR. */
827 # if defined (__STDC__) || defined (__cplusplus)
828 yystrlen (const char *yystr
)
834 const char *yys
= yystr
;
836 while (*yys
++ != '\0')
839 return yys
- yystr
- 1;
845 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
846 # define yystpcpy stpcpy
848 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
851 # if defined (__STDC__) || defined (__cplusplus)
852 yystpcpy (char *yydest
, const char *yysrc
)
854 yystpcpy (yydest
, yysrc
)
860 const char *yys
= yysrc
;
862 while ((*yyd
++ = *yys
++) != '\0')
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
879 yytnamerr (char *yyres
, const char *yystr
)
884 char const *yyp
= yystr
;
891 goto do_not_strip_quotes
;
895 goto do_not_strip_quotes
;
908 do_not_strip_quotes
: ;
912 return yystrlen (yystr
);
914 return yystpcpy (yyres
, yystr
) - yyres
;
918 #endif /* YYERROR_VERBOSE */
923 /*--------------------------------.
924 | Print this symbol on YYOUTPUT. |
925 `--------------------------------*/
927 #if defined (__STDC__) || defined (__cplusplus)
929 yysymprint (FILE *yyoutput
, int yytype
, YYSTYPE
*yyvaluep
)
932 yysymprint (yyoutput
, yytype
, yyvaluep
)
938 /* Pacify ``unused variable'' warnings. */
941 if (yytype
< YYNTOKENS
)
942 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
944 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
948 if (yytype
< YYNTOKENS
)
949 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
956 YYFPRINTF (yyoutput
, ")");
959 #endif /* ! YYDEBUG */
960 /*-----------------------------------------------.
961 | Release the memory associated to this symbol. |
962 `-----------------------------------------------*/
964 #if defined (__STDC__) || defined (__cplusplus)
966 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
)
969 yydestruct (yymsg
, yytype
, yyvaluep
)
975 /* Pacify ``unused variable'' warnings. */
980 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
991 /* Prevent warnings from -Wmissing-prototypes. */
994 # if defined (__STDC__) || defined (__cplusplus)
995 int yyparse (void *YYPARSE_PARAM
);
999 #else /* ! YYPARSE_PARAM */
1000 #if defined (__STDC__) || defined (__cplusplus)
1005 #endif /* ! YYPARSE_PARAM */
1009 /* The look-ahead symbol. */
1012 /* The semantic value of the look-ahead symbol. */
1015 /* Number of syntax errors so far. */
1024 #ifdef YYPARSE_PARAM
1025 # if defined (__STDC__) || defined (__cplusplus)
1026 int yyparse (void *YYPARSE_PARAM
)
1028 int yyparse (YYPARSE_PARAM
)
1029 void *YYPARSE_PARAM
;
1031 #else /* ! YYPARSE_PARAM */
1032 #if defined (__STDC__) || defined (__cplusplus)
1044 /* Number of tokens to shift before error messages enabled. */
1046 /* Look-ahead token as an internal (translated) token number. */
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
;
1062 /* The semantic value stack. */
1063 YYSTYPE yyvsa
[YYINITDEPTH
];
1064 YYSTYPE
*yyvs
= yyvsa
;
1069 #define YYPOPSTACK (yyvsp--, yyssp--)
1071 YYSIZE_T yystacksize
= YYINITDEPTH
;
1073 /* The variables used to return semantic value and location from the
1078 /* When reducing, the number of symbols on the RHS of the reduced
1082 YYDPRINTF ((stderr
, "Starting parse\n"));
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. */
1099 /*------------------------------------------------------------.
1100 | yynewstate -- Push a new state, which is found in yystate. |
1101 `------------------------------------------------------------*/
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.
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;
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
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
),
1138 #else /* no yyoverflow */
1139 # ifndef YYSTACK_RELOCATE
1140 goto yyexhaustedlab
;
1142 /* Extend the stack our own way. */
1143 if (YYMAXDEPTH
<= yystacksize
)
1144 goto yyexhaustedlab
;
1146 if (YYMAXDEPTH
< yystacksize
)
1147 yystacksize
= YYMAXDEPTH
;
1150 short int *yyss1
= yyss
;
1151 union yyalloc
*yyptr
=
1152 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1154 goto yyexhaustedlab
;
1155 YYSTACK_RELOCATE (yyss
);
1156 YYSTACK_RELOCATE (yyvs
);
1158 # undef YYSTACK_RELOCATE
1160 YYSTACK_FREE (yyss1
);
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
)
1176 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1185 /* Do appropriate processing given the current state. */
1186 /* Read a look-ahead token if we need one and don't already have one. */
1189 /* First try to decide what to do without reference to look-ahead token. */
1191 yyn
= yypact
[yystate
];
1192 if (yyn
== YYPACT_NINF
)
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: "));
1204 if (yychar
<= YYEOF
)
1206 yychar
= yytoken
= YYEOF
;
1207 YYDPRINTF ((stderr
, "Now at end of input.\n"));
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. */
1218 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1223 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
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
)
1242 /* Count tokens shifted since error; after three, turn off error
1251 /*-----------------------------------------------------------.
1252 | yydefault -- do the default action for the current state. |
1253 `-----------------------------------------------------------*/
1255 yyn
= yydefact
[yystate
];
1261 /*-----------------------------.
1262 | yyreduce -- Do a reduction. |
1263 `-----------------------------*/
1265 /* yyn is the number of a rule to reduce with. */
1268 /* If YYLEN is nonzero, implement the default value of the action:
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
);
1283 #line 91 "find_dep.y"
1285 if (strcasecmp((yyvsp
[-1].string
), "interface") == 0)
1286 in_interface
= true;
1287 free((yyvsp
[-1].string
));
1292 #line 96 "find_dep.y"
1294 if (strcasecmp((yyvsp
[-3].string
), "use") == 0) {
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
))) {
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
));
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
));
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
));
1347 #line 143 "find_dep.y"
1349 handle_include((yyvsp
[-2].string
));
1350 free((yyvsp
[-2].string
));
1355 #line 148 "find_dep.y"
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
, ¯ocmp
))
1362 macrolist
= list_prepend(macrolist
, defmac
);
1368 #line 157 "find_dep.y"
1375 macro_setname(mac
, (yyvsp
[-2].string
));
1377 l
= list_find(macrolist
, mac
, ¯ocmp
);
1379 macrolist
= list_remove(macrolist
, l
);
1380 macro_free(l
->data
);
1389 #line 174 "find_dep.y"
1394 macro_setname(mac
, (yyvsp
[-2].string
));
1399 else if (!list_find(macrolist
, mac
, ¯ocmp
))
1402 skip_to_end
[skip_i
] = true;
1409 #line 190 "find_dep.y"
1414 macro_setname(mac
, (yyvsp
[-2].string
));
1419 if (list_find(macrolist
, mac
, ¯ocmp
))
1422 skip_to_end
[skip_i
] = true;
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'). */
1435 if (pp_ignore
) pp_ignore
++;
1436 skip_to_end
[skip_i
] = false;
1441 #line 214 "find_dep.y"
1443 /* Allways taken unless an #ifdef or #ifndef-branch has been taken
1445 if (skip_to_end
[skip_i
] && pp_ignore
== 0) pp_ignore
= 1;
1450 #line 219 "find_dep.y"
1452 if (pp_ignore
== 1 && skip_to_end
[skip_i
] == false)
1454 else if (pp_ignore
== 0)
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
--;
1469 #line 233 "find_dep.y"
1474 #line 277 "find_dep.y"
1475 { free ((yyvsp
[0].string
)); }
1479 #line 278 "find_dep.y"
1480 { free ((yyvsp
[0].string
)); }
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
));
1496 /* Line 1126 of yacc.c. */
1497 #line 1500 "y.tab.c"
1503 YY_STACK_PRINT (yyss
, yyssp
);
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. */
1514 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1515 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1516 yystate
= yytable
[yystate
];
1518 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1523 /*------------------------------------.
1524 | yyerrlab -- here on detecting error |
1525 `------------------------------------*/
1527 /* If not already recovering from an error, report this error. */
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
;
1540 int yysize_overflow
= 0;
1542 # define YYERROR_VERBOSE_ARGS_MAXIMUM 5
1543 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
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");
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
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
;
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
)
1585 yyformat
[sizeof yyunexpected
- 1] = '\0';
1588 yyarg
[yycount
++] = yytname
[yyx
];
1589 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1590 yysize_overflow
|= yysize1
< yysize
;
1592 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1596 yyf
= YY_(yyformat
);
1597 yysize1
= yysize
+ yystrlen (yyf
);
1598 yysize_overflow
|= yysize1
< yysize
;
1601 if (!yysize_overflow
&& yysize
<= YYSTACK_ALLOC_MAXIMUM
)
1602 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
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. */
1610 while ((*yyp
= *yyf
))
1612 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1614 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1624 YYSTACK_FREE (yymsg
);
1628 yyerror (YY_("syntax error"));
1629 goto yyexhaustedlab
;
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
)
1652 yydestruct ("Error: discarding", yytoken
, &yylval
);
1657 /* Else will try to reuse look-ahead token after shifting the error
1662 /*---------------------------------------------------.
1663 | yyerrorlab -- error raised explicitly by YYERROR. |
1664 `---------------------------------------------------*/
1667 /* Pacify compilers like GCC when the user code never invokes
1668 YYERROR and the label yyerrorlab therefore never appears in user
1679 /*-------------------------------------------------------------.
1680 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1681 `-------------------------------------------------------------*/
1683 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1687 yyn
= yypact
[yystate
];
1688 if (yyn
!= YYPACT_NINF
)
1691 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1699 /* Pop the current state because it cannot handle the error token. */
1704 yydestruct ("Error: popping", yystos
[yystate
], yyvsp
);
1707 YY_STACK_PRINT (yyss
, yyssp
);
1716 /* Shift the error token. */
1717 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1723 /*-------------------------------------.
1724 | yyacceptlab -- YYACCEPT comes here. |
1725 `-------------------------------------*/
1730 /*-----------------------------------.
1731 | yyabortlab -- YYABORT comes here. |
1732 `-----------------------------------*/
1738 /*-------------------------------------------------.
1739 | yyexhaustedlab -- memory exhaustion comes here. |
1740 `-------------------------------------------------*/
1742 yyerror (YY_("memory exhausted"));
1748 if (yychar
!= YYEOF
&& yychar
!= YYEMPTY
)
1749 yydestruct ("Cleanup: discarding lookahead",
1751 while (yyssp
!= yyss
)
1753 yydestruct ("Cleanup: popping",
1754 yystos
[*yyssp
], yyvsp
);
1759 YYSTACK_FREE (yyss
);
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
);
1779 /* Return false for failure reading file, else return true. */
1781 bool find_dep(char *file
, Dependency
*d
, List
**mods
, const List
*predef_macro
)
1784 extern int yylineno
;
1797 yyin
= open_src_file(file
, options
.src_path
);
1799 warning("Skipping file '%s': %s", file
, strerror(errno
));
1803 /* Check source format */
1804 if (options
.src_fmt
== SUFFIX
)
1805 lex_set_format(get_format(file
));
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 */
1812 for (h
= predef_macro
; h
; h
= h
->next
) {
1814 macro_copy(mac
, (Macro
*)h
->data
);
1815 if (!list_find(macrolist
, mac
, ¯ocmp
))
1816 macrolist
= list_prepend(macrolist
, mac
);
1822 /* Delete macrolist */
1823 for (h
= macrolist
; h
; h
= h
->next
)
1824 macro_free((Macro
*)h
->data
);
1825 list_free(macrolist
);
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
)
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
;
1878 void pop_filestack()
1880 curr_file
= filestack
[--filestack_i
];
1884 void handle_include(const char *incfile
)
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
);
1900 Module
*module_new()
1904 m
= (Module
*) xmalloc(sizeof(Module
));
1905 m
->modulename
= m
->modfile_name
= m
->sourcefile
= NULL
;
1910 Dependency
*dependency_new()
1914 d
= (Dependency
*) xmalloc(sizeof(Dependency
));
1915 d
->sourcefile
= NULL
;
1916 d
->targets
= d
->modules
= d
->includes
= NULL
;