summaryrefslogtreecommitdiffstats
path: root/match.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-01-22 06:12:24 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-01-22 06:12:24 -0800
commita928f32d7f83e7cb0cbf7a7251d3edd5ca5487ce (patch)
tree1aabfe9013641554fee6f11f43412780c06550a0 /match.h
parent1468f3fc7fba26345de8a67b66d4af5367c13037 (diff)
downloadtxr-a928f32d7f83e7cb0cbf7a7251d3edd5ca5487ce.tar.gz
txr-a928f32d7f83e7cb0cbf7a7251d3edd5ca5487ce.tar.bz2
txr-a928f32d7f83e7cb0cbf7a7251d3edd5ca5487ce.zip
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.
Diffstat (limited to 'match.h')
-rw-r--r--match.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/match.h b/match.h
index a3b19f0f..eb369495 100644
--- a/match.h
+++ b/match.h
@@ -27,11 +27,14 @@
extern val text_s, choose_s, gather_s, do_s, require_s;
extern val close_s, load_s, include_s, mod_s, modlast_s, line_s;
-extern val counter_k, vars_k, env_k, var_k;
+extern val counter_k, vars_k, env_k, var_k, into_k, named_k;
val match_expand_keyword_args(val elem);
val match_expand_elem(val elem);
val match_filter(val name, val arg, val other_args);
val match_fun(val name, val args, val input, val files);
val include(val specline);
val extract(val spec, val filenames, val bindings);
+void match_reg_var(val sym);
+void match_reg_params(val params);
+void match_reg_elem(val elem);
void match_init(void);