From a928f32d7f83e7cb0cbf7a7251d3edd5ca5487ce Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 22 Jan 2017 06:12:24 -0800 Subject: Enable unbound warnings when expanding TXR code. With this change, Lisp expansion-time warnings are no longer suppressed during the parsing of the TXR pattern language. Embedded Lisp expressions can refer to TXR pattern variables, which generates spurious warnings that must be suppressed. Since TXR pattern variables are dynamically introduced in a very flexible way, it's hard to do an exact job of this. We take the crude approach that warnings are suppressed for all pattern variables that appear anywhere in the TXR code. To do that, we identify, at parse time, all directives which can bind new variables, and register those variables as if they were tentative global defs, purging all pending warnings for them. * match.c (binding_directive_table): New static hash table. (match_reg_var, match_reg_params, match_reg_elem): New functions. (match_reg_var_rec): New static function. (dir_tables_init): gc-protect binding_directive_table, and populate its entries. * match.h (into_k, named_k): Declared. (match_reg_var, match_reg_params, match_reg_elem): Declared. * parser.y (process_catch_exprs): New static function. (elem): Call match_reg_elem for each basic directive, to process the variables in that directive according to its operator symbol. Do this for each compound form elem and variable elem. Te horizontal @(define) eleme has its own grammar production here, and we handle its parameter list in that rule. (define_clause): Handle the parameters of a vertical @(define). It binds pattern variables, and so we must suppress unbound warnings for those. (catch_clauses_opt): Process the parameters bound by @(catch) clauses. (output_clause): Suppress warnings for the variables nominated by any :into or :named argument. (expand_repeat_rep_args): Suppress warnings for :counter variable, and for :vars variables. (parse_once): Remove the warning-muffling handler frame set up around the yyparse call. * txr.c (txr_main): Suppress warnings for TXR variables defined using -D syntax on the command line. Dump deferred warnings after parsing a .txr file. --- txr.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'txr.c') diff --git a/txr.c b/txr.c index cc5fe87a..50022f15 100644 --- a/txr.c +++ b/txr.c @@ -591,6 +591,8 @@ int txr_main(int argc, char **argv) else bindings = cons(cons(sym, t), bindings); + match_reg_var(sym); + continue; } @@ -976,6 +978,8 @@ int txr_main(int argc, char **argv) close_stream(parse_stream, nil); + uw_dump_deferred_warnings(std_error); + if (parser.errors) return EXIT_FAILURE; -- cgit v1.2.3