diff --git a/driver/Makefile.in b/driver/Makefile.in index d9d1c18e0..e60f51242 100644 --- a/driver/Makefile.in +++ b/driver/Makefile.in @@ -18,7 +18,7 @@ # 59 Temple Place - Suite 330 # 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 @@ -81,7 +81,7 @@ build_string.o: build_string.c globals.h lexor.o: lexor.c parse.h globals.h parse.o: parse.c 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 man -t $(srcdir)/iverilog.man | ps2pdf - iverilog.pdf diff --git a/driver/cflexor.lex b/driver/cflexor.lex index 26ec6a901..1d9360d35 100644 --- a/driver/cflexor.lex +++ b/driver/cflexor.lex @@ -19,11 +19,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 # include "cfparse.h" # include "cfparse_misc.h" +# include "globals.h" # include /* @@ -37,6 +38,8 @@ YYLTYPE yylloc; static int comment_enter; +static int plus_incdir(void); + %} %x CCOMMENT @@ -63,28 +66,47 @@ static int comment_enter; /* Skip line ends, but also count the line. */ \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; } "/"[^\*\/].* { cflval.text = strdup(yytext); - return TOK_STRING; } + return TOK_STRING; } -[^/\n \t\b\r-].* { cflval.text = strdup(yytext); - return TOK_STRING; } +[^/\n \t\b\r+-].* { cflval.text = strdup(yytext); + return TOK_STRING; } /* Fallback match. */ . { return yytext[0]; } %% +static int plus_incdir(void) +{ + cflval.text = strdup(yytext + strlen("+incdir+")); + return TOK_INCDIR; +} + int yywrap() { return 1; } -void cfreset(FILE*fd) +void cfreset(FILE*fd, const char*path) { yyin = fd; yyrestart(fd); yylloc.first_line = 1; - yylloc.text = ""; + yylloc.text = (char*)path; } diff --git a/driver/cfparse.y b/driver/cfparse.y index 8da47ed8c..a20a94707 100644 --- a/driver/cfparse.y +++ b/driver/cfparse.y @@ -18,19 +18,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 # include "globals.h" + %} %union { char*text; }; -%token TOK_Dy -%token TOK_STRING +%token TOK_Da TOK_Dv TOK_Dy +%token TOK_INCDIR TOK_PLUSARG TOK_STRING %% @@ -48,10 +49,27 @@ item : TOK_STRING { process_file_name($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 { process_library_switch($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); + } ; %% diff --git a/driver/cfparse_misc.h b/driver/cfparse_misc.h index 989534f6e..41886ad10 100644 --- a/driver/cfparse_misc.h +++ b/driver/cfparse_misc.h @@ -20,27 +20,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 -/* - * 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 $ + * 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 * More sophisticated command file parser. * diff --git a/driver/globals.h b/driver/globals.h index d8faa9858..0913fe56f 100644 --- a/driver/globals.h +++ b/driver/globals.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 # include @@ -57,6 +57,9 @@ extern void process_file_name(const char*name); /* Add the name to the list of library directories. */ extern void process_library_switch(const char*name); + /* Add a new include file search directory */ +extern void process_include_dir(const char*name); + /* -v */ extern int verbose_flag; @@ -71,6 +74,10 @@ extern int build_string(char*out, size_t olen, const char*pattern); /* * $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 * More sophisticated command file parser. * diff --git a/driver/main.c b/driver/main.c index 92b325139..4d2e0dc61 100644 --- a/driver/main.c +++ b/driver/main.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * 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" @@ -79,6 +79,8 @@ const char sep = '\\'; const char sep = '/'; #endif +extern void cfreset(FILE*fd, const char*path); + const char*base = 0; const char*mtm = 0; const char*opath = "a.out" EXEEXT; @@ -282,6 +284,21 @@ void process_library_switch(const char *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) { if (src_list) { @@ -391,18 +408,9 @@ int main(int argc, char **argv) return 1; case 'I': - if (inc_list == 0) { - 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); - } + process_include_dir(optarg); break; + case 'm': if (mod_list == 0) { mod_list = malloc(strlen(" -m")+strlen(optarg)+1); @@ -482,8 +490,13 @@ int main(int argc, char **argv) return 1; } - cfreset(fp); + cfreset(fp, command_filename); 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 @@ -587,6 +600,10 @@ int main(int argc, char **argv) /* * $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 * More sophisticated command file parser. *