2001-11-12 02:26:36 +01:00
|
|
|
%{
|
|
|
|
|
/*
|
2014-02-27 20:20:20 +01:00
|
|
|
* Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
|
2001-11-12 02:26:36 +01:00
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-08-29 03:41:23 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2001-11-12 02:26:36 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# include "globals.h"
|
2002-01-02 03:39:34 +01:00
|
|
|
# include "cfparse_misc.h"
|
2001-12-08 05:13:07 +01:00
|
|
|
# include <ctype.h>
|
2003-09-26 23:25:58 +02:00
|
|
|
# include <stdlib.h>
|
2011-04-27 20:03:08 +02:00
|
|
|
# include <stdio.h>
|
2003-09-26 23:25:58 +02:00
|
|
|
# include <string.h>
|
2011-10-12 20:51:00 +02:00
|
|
|
# include "ivl_alloc.h"
|
2003-09-26 23:25:58 +02:00
|
|
|
|
2001-12-08 05:13:07 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This flag is set to 0, 1 or 2 if file names are to be translated to
|
|
|
|
|
* uppercase(1) or lowercase(2).
|
|
|
|
|
*/
|
|
|
|
|
static int setcase_filename_flag = 0;
|
|
|
|
|
static void translate_file_name(char*text)
|
|
|
|
|
{
|
|
|
|
|
switch (setcase_filename_flag) {
|
|
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
while (*text) {
|
2010-04-11 20:00:39 +02:00
|
|
|
*text = toupper((int)*text);
|
2001-12-08 05:13:07 +01:00
|
|
|
text += 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
while (*text) {
|
2010-04-11 20:00:39 +02:00
|
|
|
*text = tolower((int)*text);
|
2001-12-08 05:13:07 +01:00
|
|
|
text += 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-11-12 19:47:32 +01:00
|
|
|
|
2001-11-12 02:26:36 +01:00
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
%union {
|
|
|
|
|
char*text;
|
|
|
|
|
};
|
|
|
|
|
|
2007-09-30 02:48:36 +02:00
|
|
|
%token TOK_Da TOK_Dc TOK_Dv TOK_Dy
|
2009-12-30 05:23:58 +01:00
|
|
|
%token TOK_DEFINE TOK_INCDIR TOK_INTEGER_WIDTH TOK_LIBDIR TOK_LIBDIR_NOCASE
|
2011-07-31 03:18:03 +02:00
|
|
|
%token TOK_LIBEXT TOK_PARAMETER TOK_TIMESCALE TOK_VHDL_WORK TOK_VHDL_LIBDIR
|
2014-02-27 20:20:20 +01:00
|
|
|
%token TOK_WIDTH_CAP
|
2001-11-13 04:30:26 +01:00
|
|
|
%token <text> TOK_PLUSARG TOK_PLUSWORD TOK_STRING
|
2001-11-12 02:26:36 +01:00
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
start
|
|
|
|
|
:
|
|
|
|
|
| item_list
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
item_list
|
|
|
|
|
: item_list item
|
|
|
|
|
| item
|
|
|
|
|
;
|
|
|
|
|
|
2001-11-13 04:30:26 +01:00
|
|
|
item
|
|
|
|
|
/* Absent any other matching, a token string is taken to be the name
|
|
|
|
|
of a source file. Add the file to the file list. */
|
|
|
|
|
|
|
|
|
|
: TOK_STRING
|
2002-06-23 22:10:51 +02:00
|
|
|
{ char*tmp = substitutions($1);
|
|
|
|
|
translate_file_name(tmp);
|
2007-04-19 04:52:53 +02:00
|
|
|
process_file_name(tmp, 0);
|
2001-11-12 02:26:36 +01:00
|
|
|
free($1);
|
2002-06-23 22:10:51 +02:00
|
|
|
free(tmp);
|
2001-11-12 02:26:36 +01:00
|
|
|
}
|
2001-11-13 04:30:26 +01:00
|
|
|
|
|
|
|
|
/* The -a flag is completely ignored. */
|
|
|
|
|
|
|
|
|
|
| TOK_Da { }
|
|
|
|
|
|
2007-09-30 02:48:36 +02:00
|
|
|
/* Match a -c <cmdfile> or -f <cmdfile> */
|
|
|
|
|
|
|
|
|
|
| TOK_Dc TOK_STRING
|
|
|
|
|
{ char*tmp = substitutions($2);
|
|
|
|
|
translate_file_name(tmp);
|
|
|
|
|
switch_to_command_file(tmp);
|
|
|
|
|
free($2);
|
|
|
|
|
free(tmp);
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-13 04:30:26 +01:00
|
|
|
/* The -v <libfile> flag is ignored, and the <libfile> is processed
|
|
|
|
|
as an ordinary source file. */
|
|
|
|
|
|
2001-11-12 19:47:32 +01:00
|
|
|
| TOK_Dv TOK_STRING
|
2002-06-23 22:10:51 +02:00
|
|
|
{ char*tmp = substitutions($2);
|
|
|
|
|
translate_file_name(tmp);
|
2007-04-19 04:52:53 +02:00
|
|
|
process_file_name(tmp, 1);
|
2001-11-12 19:47:32 +01:00
|
|
|
free($2);
|
2002-06-23 22:10:51 +02:00
|
|
|
free(tmp);
|
2001-11-12 19:47:32 +01:00
|
|
|
}
|
2001-11-13 04:30:26 +01:00
|
|
|
|
|
|
|
|
/* This rule matches "-y <path>" sequences. This does the same thing
|
|
|
|
|
as -y on the command line, so add the path to the library
|
|
|
|
|
directory list. */
|
|
|
|
|
|
2001-11-12 02:26:36 +01:00
|
|
|
| TOK_Dy TOK_STRING
|
2002-06-23 22:10:51 +02:00
|
|
|
{ char*tmp = substitutions($2);
|
|
|
|
|
process_library_switch(tmp);
|
2001-11-12 02:26:36 +01:00
|
|
|
free($2);
|
2002-06-23 22:10:51 +02:00
|
|
|
free(tmp);
|
2001-11-12 02:26:36 +01:00
|
|
|
}
|
2001-11-13 04:30:26 +01:00
|
|
|
|
2002-05-28 22:40:37 +02:00
|
|
|
| TOK_LIBDIR TOK_PLUSARG
|
2002-06-23 22:10:51 +02:00
|
|
|
{ char*tmp = substitutions($2);
|
|
|
|
|
process_library_switch(tmp);
|
2002-05-28 22:40:37 +02:00
|
|
|
free($2);
|
2002-06-23 22:10:51 +02:00
|
|
|
free(tmp);
|
2002-05-28 22:40:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
| TOK_LIBDIR_NOCASE TOK_PLUSARG
|
2002-06-23 22:10:51 +02:00
|
|
|
{ char*tmp = substitutions($2);
|
|
|
|
|
process_library_nocase_switch(tmp);
|
2002-05-28 22:40:37 +02:00
|
|
|
free($2);
|
2002-06-23 22:10:51 +02:00
|
|
|
free(tmp);
|
2002-05-28 22:40:37 +02:00
|
|
|
}
|
|
|
|
|
|
2009-08-06 23:42:13 +02:00
|
|
|
| TOK_PARAMETER TOK_PLUSARG
|
|
|
|
|
{ char*tmp = substitutions($2);
|
|
|
|
|
process_parameter(tmp);
|
|
|
|
|
free($2);
|
|
|
|
|
free(tmp);
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-30 05:23:58 +01:00
|
|
|
/* The +timescale token is used to set the default timescale for
|
|
|
|
|
the simulator. */
|
|
|
|
|
| TOK_TIMESCALE TOK_PLUSARG
|
|
|
|
|
{ char*tmp = substitutions($2);
|
|
|
|
|
process_timescale(tmp);
|
|
|
|
|
free($2);
|
|
|
|
|
free(tmp);
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-13 04:30:26 +01:00
|
|
|
| TOK_DEFINE TOK_PLUSARG
|
|
|
|
|
{ process_define($2);
|
|
|
|
|
free($2);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-25 00:24:32 +02:00
|
|
|
| TOK_VHDL_WORK TOK_PLUSARG
|
|
|
|
|
{ char*tmp = substitutions($2);
|
|
|
|
|
vhdlpp_work = tmp;
|
|
|
|
|
free($2);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-31 03:18:03 +02:00
|
|
|
| TOK_VHDL_LIBDIR TOK_PLUSARG
|
|
|
|
|
{ char*tmp = substitutions($2);
|
|
|
|
|
vhdlpp_libdir = realloc(vhdlpp_libdir, (vhdlpp_libdir_cnt+1)*sizeof(char*));
|
|
|
|
|
vhdlpp_libdir[vhdlpp_libdir_cnt] = tmp;
|
|
|
|
|
vhdlpp_libdir_cnt += 1;
|
|
|
|
|
free($2);
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-13 04:30:26 +01:00
|
|
|
/* The +incdir token introduces a list of +<path> arguments that are
|
|
|
|
|
the include directories to search. */
|
|
|
|
|
|
|
|
|
|
| TOK_INCDIR inc_args
|
|
|
|
|
|
2001-11-16 06:07:19 +01:00
|
|
|
/* The +libext token introduces a list of +<ext> arguments that
|
|
|
|
|
become individual -Y flags to ivl. */
|
|
|
|
|
|
|
|
|
|
| TOK_LIBEXT libext_args
|
|
|
|
|
|
2007-03-07 05:24:59 +01:00
|
|
|
/* These are various misc flags that are supported. */
|
|
|
|
|
|
|
|
|
|
| TOK_INTEGER_WIDTH TOK_PLUSARG
|
|
|
|
|
{ char*tmp = substitutions($2);
|
|
|
|
|
free($2);
|
|
|
|
|
integer_width = strtoul(tmp,0,10);
|
|
|
|
|
free(tmp);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-27 20:20:20 +01:00
|
|
|
| TOK_WIDTH_CAP TOK_PLUSARG
|
|
|
|
|
{ char*tmp = substitutions($2);
|
|
|
|
|
free($2);
|
|
|
|
|
width_cap = strtoul(tmp,0,10);
|
|
|
|
|
free(tmp);
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-13 04:30:26 +01:00
|
|
|
/* The +<word> tokens that are not otherwise matched, are
|
|
|
|
|
ignored. The skip_args rule arranges for all the argument words
|
|
|
|
|
to be consumed. */
|
|
|
|
|
|
|
|
|
|
| TOK_PLUSWORD skip_args
|
|
|
|
|
{ fprintf(stderr, "%s:%u: Ignoring %s\n",
|
|
|
|
|
@1.text, @1.first_line, $1);
|
2001-11-12 19:47:32 +01:00
|
|
|
free($1);
|
|
|
|
|
}
|
2001-11-13 04:30:26 +01:00
|
|
|
| TOK_PLUSWORD
|
2001-12-08 05:13:07 +01:00
|
|
|
{ if (strcmp($1, "+toupper-filenames") == 0) {
|
|
|
|
|
setcase_filename_flag = 1;
|
|
|
|
|
} else if (strcmp($1, "+tolower-filenames") == 0) {
|
|
|
|
|
setcase_filename_flag = 2;
|
|
|
|
|
} else {
|
|
|
|
|
fprintf(stderr, "%s:%u: Ignoring %s\n",
|
|
|
|
|
@1.text, @1.first_line, $1);
|
|
|
|
|
}
|
2001-11-12 19:47:32 +01:00
|
|
|
free($1);
|
|
|
|
|
}
|
2007-09-30 02:48:36 +02:00
|
|
|
|
|
|
|
|
| error
|
2014-06-30 05:38:23 +02:00
|
|
|
{ fprintf(stderr, "Error: unable to parse line %u in "
|
2007-09-30 02:48:36 +02:00
|
|
|
"%s.\n", cflloc.first_line, current_file);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2001-11-12 02:26:36 +01:00
|
|
|
;
|
|
|
|
|
|
2001-11-13 04:30:26 +01:00
|
|
|
/* inc_args are +incdir+ arguments in order. */
|
|
|
|
|
inc_args
|
|
|
|
|
: inc_args inc_arg
|
|
|
|
|
| inc_arg
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
inc_arg : TOK_PLUSARG
|
2002-06-23 22:10:51 +02:00
|
|
|
{ char*tmp = substitutions($1);
|
|
|
|
|
process_include_dir(tmp);
|
2001-11-13 04:30:26 +01:00
|
|
|
free($1);
|
2002-06-23 22:10:51 +02:00
|
|
|
free(tmp);
|
2001-11-13 04:30:26 +01:00
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
2001-11-16 06:07:19 +01:00
|
|
|
/* inc_args are +incdir+ arguments in order. */
|
|
|
|
|
libext_args
|
|
|
|
|
: libext_args libext_arg
|
|
|
|
|
| libext_arg
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
libext_arg : TOK_PLUSARG
|
|
|
|
|
{ process_library2_switch($1);
|
|
|
|
|
free($1);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
2001-11-13 04:30:26 +01:00
|
|
|
/* skip_args are arguments to a +word flag that is not otherwise
|
|
|
|
|
parsed. This rule matches them and releases the strings, so that
|
|
|
|
|
they can be safely ignored. */
|
|
|
|
|
skip_args
|
|
|
|
|
: skip_args skip_arg
|
|
|
|
|
| skip_arg
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
skip_arg : TOK_PLUSARG
|
|
|
|
|
{ free($1);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
2001-11-12 02:26:36 +01:00
|
|
|
%%
|
|
|
|
|
|
2020-11-27 01:11:59 +01:00
|
|
|
int command_file_errors = 0;
|
|
|
|
|
|
2001-11-12 02:26:36 +01:00
|
|
|
int yyerror(const char*msg)
|
|
|
|
|
{
|
2014-07-09 23:16:57 +02:00
|
|
|
(void)msg; /* Parameter is not used. */
|
2020-11-27 01:11:59 +01:00
|
|
|
command_file_errors += 1;
|
2003-09-26 23:25:58 +02:00
|
|
|
return 0;
|
2001-11-12 02:26:36 +01:00
|
|
|
}
|