undefined macros are null (with warnings.)
This commit is contained in:
parent
67472379b4
commit
063d56ffc1
|
|
@ -19,13 +19,13 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: globals.h,v 1.4 2000/08/20 17:49:04 steve Exp $"
|
||||
#ident "$Id: globals.h,v 1.5 2000/09/13 22:33:13 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
extern void reset_lexor(FILE*out, char*paths[]);
|
||||
extern void define_macro(const char*name, const char*value);
|
||||
extern void define_macro(const char*name, const char*value, int keyword);
|
||||
|
||||
/* These variables contain the include directories to be searched when
|
||||
an include directive in encountered. */
|
||||
|
|
@ -42,6 +42,9 @@ extern int yyparse();
|
|||
|
||||
/*
|
||||
* $Log: globals.h,v $
|
||||
* Revision 1.5 2000/09/13 22:33:13 steve
|
||||
* undefined macros are null (with warnings.)
|
||||
*
|
||||
* Revision 1.4 2000/08/20 17:49:04 steve
|
||||
* Clean up warnings and portability issues.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: lexor.lex,v 1.20 2000/08/20 17:49:04 steve Exp $"
|
||||
#ident "$Id: lexor.lex,v 1.21 2000/09/13 22:33:13 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
|
|
@ -216,6 +216,8 @@ W [ \t\b\f]+
|
|||
struct define_t {
|
||||
char*name;
|
||||
char*value;
|
||||
/* keywords don't get rescanned for fresh values. */
|
||||
int keyword;
|
||||
|
||||
struct define_t*left, *right, *up;
|
||||
};
|
||||
|
|
@ -255,8 +257,14 @@ static void def_match()
|
|||
struct define_t*cur = def_lookup(yytext+1);
|
||||
|
||||
if (cur) {
|
||||
struct include_stack_t*isp
|
||||
= calloc(1, sizeof(struct include_stack_t));
|
||||
struct include_stack_t*isp;
|
||||
|
||||
if (cur->keyword) {
|
||||
fprintf(yyout, "%s", cur->value);
|
||||
return;
|
||||
}
|
||||
|
||||
isp = calloc(1, sizeof(struct include_stack_t));
|
||||
isp->str = cur->value;
|
||||
isp->next = istack;
|
||||
istack->yybs = YY_CURRENT_BUFFER;
|
||||
|
|
@ -264,7 +272,9 @@ static void def_match()
|
|||
yy_switch_to_buffer(yy_new_buffer(istack->file, YY_BUF_SIZE));
|
||||
|
||||
} else {
|
||||
fprintf(yyout, "%s", yytext);
|
||||
fprintf(stderr, "%s:%u: warning: macro %s undefined "
|
||||
"(and assumed null) at this point.\n",
|
||||
istack->path, istack->lineno, yytext);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -275,11 +285,12 @@ static void def_start()
|
|||
sscanf(yytext, "`define %s", def_name);
|
||||
}
|
||||
|
||||
void define_macro(const char*name, const char*value)
|
||||
void define_macro(const char*name, const char*value, int keyword)
|
||||
{
|
||||
struct define_t*def = malloc(sizeof(struct define_t));
|
||||
def->name = strdup(name);
|
||||
def->value = strdup(value);
|
||||
def->keyword = keyword;
|
||||
def->left = 0;
|
||||
def->right = 0;
|
||||
def->up = 0;
|
||||
|
|
@ -339,14 +350,14 @@ static void do_define()
|
|||
*cp = 0;
|
||||
}
|
||||
|
||||
define_macro(def_name, yytext);
|
||||
define_macro(def_name, yytext, 0);
|
||||
def_name[0] = 0;
|
||||
}
|
||||
|
||||
static void def_finish()
|
||||
{
|
||||
if (def_name[0])
|
||||
define_macro(def_name, "1");
|
||||
define_macro(def_name, "1", 0);
|
||||
}
|
||||
|
||||
static void def_undefine()
|
||||
|
|
|
|||
37
ivlpp/main.c
37
ivlpp/main.c
|
|
@ -17,7 +17,7 @@ const char COPYRIGHT[] =
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: main.c,v 1.6 2000/08/20 17:49:05 steve Exp $"
|
||||
#ident "$Id: main.c,v 1.7 2000/09/13 22:33:13 steve Exp $"
|
||||
#endif
|
||||
|
||||
const char NOTICE[] =
|
||||
|
|
@ -61,11 +61,29 @@ int main(int argc, char*argv[])
|
|||
char*out_path = 0;
|
||||
FILE*out;
|
||||
|
||||
/* Define preprocessor keywords that I plan to just pass. */
|
||||
define_macro("celldefine", "`celldefine", 1);
|
||||
define_macro("default_nettype", "`default_nettype", 1);
|
||||
define_macro("delay_mode_distributed", "`delay_mode_distributed", 1);
|
||||
define_macro("delay_mode_unit", "`delay_mode_unit", 1);
|
||||
define_macro("delay_mode_path", "`delay_mode_path", 1);
|
||||
define_macro("disable_portfaults", "`enable_portfaults", 1);
|
||||
define_macro("endcelldefine", "`endcelldefine", 1);
|
||||
define_macro("endprotect", "`endprotect", 1);
|
||||
define_macro("nosuppress_faults", "`nosuppress_faults", 1);
|
||||
define_macro("nounconnected_drive", "`nounconnected_drive", 1);
|
||||
define_macro("protect", "`protect", 1);
|
||||
define_macro("resetall", "`resetall", 1);
|
||||
define_macro("suppress_faults", "`suppress_faults", 1);
|
||||
define_macro("timescale", "`timescale", 1);
|
||||
define_macro("unconnected_drive", "`unconnected_drive", 1);
|
||||
define_macro("uselib", "`uselib", 1);
|
||||
|
||||
include_dir = malloc(sizeof(char*));
|
||||
include_dir[0] = strdup(".");
|
||||
include_cnt = 1;
|
||||
|
||||
while ((opt = getopt(argc, argv, "D:I:Lo:v")) != EOF) switch (opt) {
|
||||
while ((opt = getopt(argc, argv, "D:I:K:Lo:v")) != EOF) switch (opt) {
|
||||
|
||||
case 'D': {
|
||||
char*tmp = strdup(optarg);
|
||||
|
|
@ -75,7 +93,7 @@ int main(int argc, char*argv[])
|
|||
else
|
||||
val = "1";
|
||||
|
||||
define_macro(tmp, val);
|
||||
define_macro(tmp, val, 0);
|
||||
free(tmp);
|
||||
break;
|
||||
}
|
||||
|
|
@ -86,6 +104,15 @@ int main(int argc, char*argv[])
|
|||
include_cnt += 1;
|
||||
break;
|
||||
|
||||
case 'K': {
|
||||
char*buf = malloc(strlen(optarg) + 2);
|
||||
buf[0] = '`';
|
||||
strcpy(buf+1, optarg);
|
||||
define_macro(optarg, buf, 1);
|
||||
free(buf);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'L':
|
||||
line_direct_flag = 1;
|
||||
break;
|
||||
|
|
@ -117,6 +144,7 @@ int main(int argc, char*argv[])
|
|||
fprintf(stderr, "\nUsage: %s [-v][-L][-I<dir>][-D<def>] <file>...\n"
|
||||
" -D<def> - Predefine a value.\n"
|
||||
" -I<dir> - Add an include file search directory\n"
|
||||
" -K<def> - Define a keyword macro that I just pass\n"
|
||||
" -L - Emit line number directives\n"
|
||||
" -o<fil> - Send the output to <fil>\n"
|
||||
" -v - Print version information\n",
|
||||
|
|
@ -148,6 +176,9 @@ int main(int argc, char*argv[])
|
|||
|
||||
/*
|
||||
* $Log: main.c,v $
|
||||
* Revision 1.7 2000/09/13 22:33:13 steve
|
||||
* undefined macros are null (with warnings.)
|
||||
*
|
||||
* Revision 1.6 2000/08/20 17:49:05 steve
|
||||
* Clean up warnings and portability issues.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue