3 * Copyright (c) 20001 Stephen Williams (steve@icarus.com)
5 * This source code is free software; you can redistribute it
6 * and/or modify it in source code form under the terms of the GNU
7 * General Public License as published by the Free Software
8 * Foundation; either version 2 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 #ident "$Id: cfparse.y,v 1.12 2007/04/19 02:52:53 steve Exp $"
26 # include "cfparse_misc.h"
33 * This flag is set to 0, 1 or 2 if file names are to be translated to
34 * uppercase(1) or lowercase(2).
36 static int setcase_filename_flag
= 0;
37 static void translate_file_name
(char*text
)
39 switch
(setcase_filename_flag
) {
44 *text
= toupper
(*text
);
50 *text
= tolower
(*text
);
63 %token TOK_Da TOK_Dc TOK_Dv TOK_Dy
64 %token TOK_DEFINE TOK_INCDIR TOK_LIBDIR TOK_LIBDIR_NOCASE TOK_LIBEXT
65 %token TOK_INTEGER_WIDTH
66 %token
<text
> TOK_PLUSARG TOK_PLUSWORD TOK_STRING
81 /* Absent any other matching, a token string is taken to be the name
82 of a source file. Add the file to the file list. */
85 { char*tmp
= substitutions
($1);
86 translate_file_name
(tmp
);
87 process_file_name
(tmp
, 0);
92 /* The -a flag is completely ignored. */
96 /* Match a -c <cmdfile> or -f <cmdfile> */
99 { char*tmp
= substitutions
($2);
100 translate_file_name
(tmp
);
101 switch_to_command_file
(tmp
);
106 /* The -v <libfile> flag is ignored, and the <libfile> is processed
107 as an ordinary source file. */
110 { char*tmp
= substitutions
($2);
111 translate_file_name
(tmp
);
112 process_file_name
(tmp
, 1);
117 /* This rule matches "-y <path>" sequences. This does the same thing
118 as -y on the command line, so add the path to the library
122 { char*tmp
= substitutions
($2);
123 process_library_switch
(tmp
);
128 | TOK_LIBDIR TOK_PLUSARG
129 { char*tmp
= substitutions
($2);
130 process_library_switch
(tmp
);
135 | TOK_LIBDIR_NOCASE TOK_PLUSARG
136 { char*tmp
= substitutions
($2);
137 process_library_nocase_switch
(tmp
);
142 | TOK_DEFINE TOK_PLUSARG
143 { process_define
($2);
147 /* The +incdir token introduces a list of +<path> arguments that are
148 the include directories to search. */
150 | TOK_INCDIR inc_args
152 /* The +libext token introduces a list of +<ext> arguments that
153 become individual -Y flags to ivl. */
155 | TOK_LIBEXT libext_args
157 /* These are various misc flags that are supported. */
159 | TOK_INTEGER_WIDTH TOK_PLUSARG
160 { char*tmp
= substitutions
($2);
162 integer_width
= strtoul
(tmp
,0,10);
166 /* The +<word> tokens that are not otherwise matched, are
167 ignored. The skip_args rule arranges for all the argument words
170 | TOK_PLUSWORD skip_args
171 { fprintf
(stderr
, "%s:%u: Ignoring %s\n",
172 @
1.text
, @
1.first_line
, $1);
176 { if
(strcmp
($1, "+toupper-filenames") == 0) {
177 setcase_filename_flag
= 1;
178 } else if
(strcmp
($1, "+tolower-filenames") == 0) {
179 setcase_filename_flag
= 2;
181 fprintf
(stderr
, "%s:%u: Ignoring %s\n",
182 @
1.text
, @
1.first_line
, $1);
188 { fprintf
(stderr
, "Error: unable to parse line %d in "
189 "%s.\n", cflloc.first_line
, current_file
);
194 /* inc_args are +incdir+ arguments in order. */
200 inc_arg
: TOK_PLUSARG
201 { char*tmp
= substitutions
($1);
202 process_include_dir
(tmp
);
208 /* inc_args are +incdir+ arguments in order. */
210 : libext_args libext_arg
214 libext_arg
: TOK_PLUSARG
215 { process_library2_switch
($1);
220 /* skip_args are arguments to a +word flag that is not otherwise
221 parsed. This rule matches them and releases the strings, so that
222 they can be safely ignored. */
228 skip_arg
: TOK_PLUSARG
235 int yyerror(const char*msg
)