summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--match.c32
-rw-r--r--parser.l2
-rw-r--r--txr.c8
-rw-r--r--txr.h1
5 files changed, 44 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 19e2d98c..e837a160 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2011-11-10 Kaz Kylheku <kaz@kylheku.com>
+ * match.c (opt_nobindings, opt_arraydims): Global
+ variables moved from parser.l.
+ (opt_lisp_bindings): New variable.
+ (dump_bindings): Dump Lisp syntax bindings
+ on standard output if opt_lisp_bindings is set.
+ (v_cat): Do not complain about trailing material;
+ this is not compatible with horizontal cat.
+
+ * parser.l (opt_nobindings, opt_arraydims): Moved
+ to match.c.
+
+ * txr.c (txr_main): New options, --lisp-bindings
+ and the equivalent -l.
+
+ * txr.h: opt_lisp_bindings declared.
+
+2011-11-10 Kaz Kylheku <kaz@kylheku.com>
+
Task #11583
* match.c (dir_tables_init): Mapping flatten_s, forget_s,
diff --git a/match.c b/match.c
index 9021c7c1..85558f1c 100644
--- a/match.c
+++ b/match.c
@@ -47,6 +47,9 @@
#include "match.h"
int output_produced;
+int opt_nobindings = 0;
+int opt_lisp_bindings = 0;
+int opt_arraydims = 1;
val decline_k, next_spec_k, repeat_spec_k;
val mingap_k, maxgap_k, gap_k, mintimes_k, maxtimes_k, times_k;
@@ -182,18 +185,20 @@ static void dump_var(val var, char *pfx1, size_t len1,
static void dump_bindings(val bindings)
{
- if (opt_loglevel >= 2) {
- put_line(std_error, lit("raw_bindings:"));
- dump(bindings, std_error);
- }
-
- while (bindings) {
- char pfx1[128], pfx2[128];
- val var = car(car(bindings));
- val value = cdr(car(bindings));
- *pfx1 = 0; *pfx2 = 0;
- dump_var(var, pfx1, 0, pfx2, 0, value, 0);
- bindings = cdr(bindings);
+ if (opt_lisp_bindings) {
+ val iter;
+ for (iter = bindings; iter; iter = cdr(iter)) {
+ dump(car(iter), std_output);
+ }
+ } else {
+ while (bindings) {
+ char pfx1[128], pfx2[128];
+ val var = car(car(bindings));
+ val value = cdr(car(bindings));
+ *pfx1 = 0; *pfx2 = 0;
+ dump_var(var, pfx1, 0, pfx2, 0, value, 0);
+ bindings = cdr(bindings);
+ }
}
}
@@ -2463,9 +2468,6 @@ static val v_cat(match_files_ctx *c)
val sym = second(first_spec);
val sep_form = third(first_spec);
- if (rest(specline))
- sem_error(spec_linenum, lit("obsolete cat syntax: trailing material"), nao);
-
if (!bindable(sym)) {
sem_error(spec_linenum,
lit("cat: ~s is not a bindable symbol"), sym, nao);
diff --git a/parser.l b/parser.l
index db95ef3e..897c6532 100644
--- a/parser.l
+++ b/parser.l
@@ -63,8 +63,6 @@ val yyin_stream;
cnum lineno = 1;
int opt_loglevel = 1; /* 0 - quiet; 1 - normal; 2 - verbose */
-int opt_nobindings = 0;
-int opt_arraydims = 1;
int errors;
diff --git a/txr.c b/txr.c
index 4c471e68..8f71f91e 100644
--- a/txr.c
+++ b/txr.c
@@ -286,8 +286,13 @@ int txr_main(int argc, char **argv)
opt_derivative_regex = 1;
argv++, argc--;
continue;
+ } else if (!strcmp(*argv, "--lisp-bindings")) {
+ opt_lisp_bindings = 1;
+ argv++, argc--;
+ continue;
}
+
{
char *popt;
for (popt = (*argv)+1; *popt != 0; popt++) {
@@ -301,6 +306,9 @@ int txr_main(int argc, char **argv)
case 'b':
opt_nobindings = 1;
break;
+ case 'l':
+ opt_lisp_bindings = 1;
+ break;
case 'a':
case 'c':
case 'D':
diff --git a/txr.h b/txr.h
index 1b0f23f7..23afc823 100644
--- a/txr.h
+++ b/txr.h
@@ -26,6 +26,7 @@
extern int opt_loglevel;
extern int opt_nobindings;
+extern int opt_lisp_bindings;
extern int opt_arraydims;
extern int opt_gc_debug;
#ifdef HAVE_VALGRIND