Support +incdir in command files, and ignore other

+args flags. Also ignore -a and -v flags.
This commit is contained in:
steve 2001-11-12 18:47:32 +00:00
parent d1ad10c90f
commit 9866fd01bd
6 changed files with 94 additions and 41 deletions

View File

@ -18,7 +18,7 @@
# 59 Temple Place - Suite 330 # 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA # Boston, MA 02111-1307, USA
# #
#ident "$Id: Makefile.in,v 1.8 2001/11/12 01:26:36 steve Exp $" #ident "$Id: Makefile.in,v 1.9 2001/11/12 18:47:32 steve Exp $"
# #
# #
SHELL = /bin/sh SHELL = /bin/sh
@ -81,7 +81,7 @@ build_string.o: build_string.c globals.h
lexor.o: lexor.c parse.h globals.h lexor.o: lexor.c parse.h globals.h
parse.o: parse.c globals.h parse.o: parse.c globals.h
cflexor.o: cflexor.c cfparse.h cfparse_misc.h globals.h cflexor.o: cflexor.c cfparse.h cfparse_misc.h globals.h
cfparse.o: cfparse.c globals.h cfparse.o: cfparse.c globals.h cfparse_misc.h
iverilog.pdf: $(srcdir)/iverilog.man iverilog.pdf: $(srcdir)/iverilog.man
man -t $(srcdir)/iverilog.man | ps2pdf - iverilog.pdf man -t $(srcdir)/iverilog.man | ps2pdf - iverilog.pdf

View File

@ -19,11 +19,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: cflexor.lex,v 1.1 2001/11/12 01:26:36 steve Exp $" #ident "$Id: cflexor.lex,v 1.2 2001/11/12 18:47:32 steve Exp $"
#endif #endif
# include "cfparse.h" # include "cfparse.h"
# include "cfparse_misc.h" # include "cfparse_misc.h"
# include "globals.h"
# include <string.h> # include <string.h>
/* /*
@ -37,6 +38,8 @@ YYLTYPE yylloc;
static int comment_enter; static int comment_enter;
static int plus_incdir(void);
%} %}
%x CCOMMENT %x CCOMMENT
@ -63,12 +66,25 @@ static int comment_enter;
/* Skip line ends, but also count the line. */ /* Skip line ends, but also count the line. */
\n { yylloc.first_line += 1; } \n { yylloc.first_line += 1; }
"+incdir+".* { return plus_incdir(); }
/* If it is not any known plus-flag, return the generic form. */
"+"[^\n \t\b\r]* { cflval.text = strdup(yytext);
return TOK_PLUSARG; }
/* Notice the -a flag. */
"-a" { return TOK_Da; }
/* Notice the -v flag. */
"-v" { return TOK_Dv; }
/* Notice the -y flag. */
"-y" { return TOK_Dy; } "-y" { return TOK_Dy; }
"/"[^\*\/].* { cflval.text = strdup(yytext); "/"[^\*\/].* { cflval.text = strdup(yytext);
return TOK_STRING; } return TOK_STRING; }
[^/\n \t\b\r-].* { cflval.text = strdup(yytext); [^/\n \t\b\r+-].* { cflval.text = strdup(yytext);
return TOK_STRING; } return TOK_STRING; }
/* Fallback match. */ /* Fallback match. */
@ -76,15 +92,21 @@ static int comment_enter;
%% %%
static int plus_incdir(void)
{
cflval.text = strdup(yytext + strlen("+incdir+"));
return TOK_INCDIR;
}
int yywrap() int yywrap()
{ {
return 1; return 1;
} }
void cfreset(FILE*fd) void cfreset(FILE*fd, const char*path)
{ {
yyin = fd; yyin = fd;
yyrestart(fd); yyrestart(fd);
yylloc.first_line = 1; yylloc.first_line = 1;
yylloc.text = ""; yylloc.text = (char*)path;
} }

View File

@ -18,19 +18,20 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: cfparse.y,v 1.1 2001/11/12 01:26:36 steve Exp $" #ident "$Id: cfparse.y,v 1.2 2001/11/12 18:47:32 steve Exp $"
#endif #endif
# include "globals.h" # include "globals.h"
%} %}
%union { %union {
char*text; char*text;
}; };
%token TOK_Dy %token TOK_Da TOK_Dv TOK_Dy
%token <text> TOK_STRING %token <text> TOK_INCDIR TOK_PLUSARG TOK_STRING
%% %%
@ -48,10 +49,27 @@ item : TOK_STRING
{ process_file_name($1); { process_file_name($1);
free($1); free($1);
} }
| TOK_Da
{ }
| TOK_Dv TOK_STRING
{ process_file_name($2);
fprintf(stderr, "%s:%u: Ignoring -v in front of %s\n",
@1.text, @1.first_line, $2);
free($2);
}
| TOK_Dy TOK_STRING | TOK_Dy TOK_STRING
{ process_library_switch($2); { process_library_switch($2);
free($2); free($2);
} }
| TOK_INCDIR
{ process_include_dir($1);
free($1);
}
| TOK_PLUSARG
{ fprintf(stderr, "%s:%u: Ignoring %s\n",
@1.text, @1.first_line, $1);
free($1);
}
; ;
%% %%

View File

@ -20,27 +20,16 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: cfparse_misc.h,v 1.1 2001/11/12 01:26:36 steve Exp $" #ident "$Id: cfparse_misc.h,v 1.2 2001/11/12 18:47:32 steve Exp $"
#endif #endif
/*
* The vlltype supports the passing of detailed source file location
* information between the lexical analyzer and the parser. Defining
* YYLTYPE compels the lexor to use this type and not something other.
*/
struct cfltype {
unsigned first_line;
unsigned first_column;
unsigned last_line;
unsigned last_column;
const char*text;
};
# define YYLTYPE struct cfltype
extern YYLTYPE yylloc;
/* /*
* $Log: cfparse_misc.h,v $ * $Log: cfparse_misc.h,v $
* Revision 1.2 2001/11/12 18:47:32 steve
* Support +incdir in command files, and ignore other
* +args flags. Also ignore -a and -v flags.
*
* Revision 1.1 2001/11/12 01:26:36 steve * Revision 1.1 2001/11/12 01:26:36 steve
* More sophisticated command file parser. * More sophisticated command file parser.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: globals.h,v 1.7 2001/11/12 01:26:36 steve Exp $" #ident "$Id: globals.h,v 1.8 2001/11/12 18:47:32 steve Exp $"
#endif #endif
# include <stddef.h> # include <stddef.h>
@ -57,6 +57,9 @@ extern void process_file_name(const char*name);
/* Add the name to the list of library directories. */ /* Add the name to the list of library directories. */
extern void process_library_switch(const char*name); extern void process_library_switch(const char*name);
/* Add a new include file search directory */
extern void process_include_dir(const char*name);
/* -v */ /* -v */
extern int verbose_flag; extern int verbose_flag;
@ -71,6 +74,10 @@ extern int build_string(char*out, size_t olen, const char*pattern);
/* /*
* $Log: globals.h,v $ * $Log: globals.h,v $
* Revision 1.8 2001/11/12 18:47:32 steve
* Support +incdir in command files, and ignore other
* +args flags. Also ignore -a and -v flags.
*
* Revision 1.7 2001/11/12 01:26:36 steve * Revision 1.7 2001/11/12 01:26:36 steve
* More sophisticated command file parser. * More sophisticated command file parser.
* *

View File

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ident "$Id: main.c,v 1.27 2001/11/12 01:26:36 steve Exp $" #ident "$Id: main.c,v 1.28 2001/11/12 18:47:32 steve Exp $"
# include "config.h" # include "config.h"
@ -79,6 +79,8 @@ const char sep = '\\';
const char sep = '/'; const char sep = '/';
#endif #endif
extern void cfreset(FILE*fd, const char*path);
const char*base = 0; const char*base = 0;
const char*mtm = 0; const char*mtm = 0;
const char*opath = "a.out" EXEEXT; const char*opath = "a.out" EXEEXT;
@ -282,6 +284,21 @@ void process_library_switch(const char *name)
strcat(library_flags, name); strcat(library_flags, name);
} }
void process_include_dir(const char *name)
{
if (inc_list == 0) {
inc_list = malloc(strlen(" -I")+strlen(name)+1);
strcpy(inc_list, " -I");
strcat(inc_list, name);
} else {
inc_list = realloc(inc_list, strlen(inc_list)
+ strlen(" -I")
+ strlen(name) + 1);
strcat(inc_list, " -I");
strcat(inc_list, name);
}
}
void process_file_name(const char*name) void process_file_name(const char*name)
{ {
if (src_list) { if (src_list) {
@ -391,18 +408,9 @@ int main(int argc, char **argv)
return 1; return 1;
case 'I': case 'I':
if (inc_list == 0) { process_include_dir(optarg);
inc_list = malloc(strlen(" -I")+strlen(optarg)+1);
strcpy(inc_list, " -I");
strcat(inc_list, optarg);
} else {
inc_list = realloc(inc_list, strlen(inc_list)
+ strlen(" -I")
+ strlen(optarg) + 1);
strcat(inc_list, " -I");
strcat(inc_list, optarg);
}
break; break;
case 'm': case 'm':
if (mod_list == 0) { if (mod_list == 0) {
mod_list = malloc(strlen(" -m")+strlen(optarg)+1); mod_list = malloc(strlen(" -m")+strlen(optarg)+1);
@ -482,8 +490,13 @@ int main(int argc, char **argv)
return 1; return 1;
} }
cfreset(fp); cfreset(fp, command_filename);
rc = cfparse(); rc = cfparse();
if (rc != 0) {
fprintf(stderr, "%s: error reading command file\n",
command_filename);
return 1;
}
} }
/* Finally, process all the remaining words on the command /* Finally, process all the remaining words on the command
@ -587,6 +600,10 @@ int main(int argc, char **argv)
/* /*
* $Log: main.c,v $ * $Log: main.c,v $
* Revision 1.28 2001/11/12 18:47:32 steve
* Support +incdir in command files, and ignore other
* +args flags. Also ignore -a and -v flags.
*
* Revision 1.27 2001/11/12 01:26:36 steve * Revision 1.27 2001/11/12 01:26:36 steve
* More sophisticated command file parser. * More sophisticated command file parser.
* *