summaryrefslogtreecommitdiffstats
path: root/tests/013
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-11-01 19:18:57 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-11-01 19:18:57 -0800
commit18dd42f65e620326bb21ffcde92004cc9705cbf8 (patch)
tree7d343914189779a0470bc74f85ba5593bab89c9e /tests/013
parentaea62af9451ce1da9db494aa07cdfb0087fa1473 (diff)
downloadtxr-18dd42f65e620326bb21ffcde92004cc9705cbf8.tar.gz
txr-18dd42f65e620326bb21ffcde92004cc9705cbf8.tar.bz2
txr-18dd42f65e620326bb21ffcde92004cc9705cbf8.zip
New range type, distinct from cons cell.
* eval.c (eval_init): Register intrinsic functions rcons, rangep from and to. (eval_init): Register rangep intrinsic. * gc.c (mark_obj): Traverse RNG objects. (finalize): Handle RNG in switch. * hash.c (equal_hash, eql_hash): Hashing for for RNG objects. * lib.c (range_s, rcons_s): New symbol variables. (code2type): Handle RNG type. (eql, equal): Equality for ranges. (less_tab_init): Table extended to cover RNG. (less): Semantics defined for ranges. (rcons, rangep, from, to): New functions. (obj_init): range_s and rcons_s variables initialized. (obj_print_impl): Produce #R notation for ranges. (generic_funcall, dwim_set): Recognize range objects for indexing * lib.h (enum type): New enum member, RNG. MAXTYPE redefined to RNG value. (TYPE_SHIFT): Increased to 5 since there are now 16 type codes. (struct range): New struct type. (union obj): New member rn, of type struct range. (range_s, rcons_s, rcons, rangep, from, to): Declared. (range_bind): New macro. * parser.l (grammar): New rule for recognizing the #R sequence as HASH_R token. * parser.y (HASH_R): New terminal symbol. (range): New nonterminal symbol. (n_expr): Derives the new range symbol. The n_expr DOTDOT n_expr rule produces rcons expression rather than const. * match.c (format_field): Recognize rcons syntax in fields which is now what ranges translate to. Also recognize range object. * tests/013/maze.tl (neigh): Fix code which destructures range as a cons. That can't be done any more. * txr.1: Document ranges.
Diffstat (limited to 'tests/013')
-rw-r--r--tests/013/maze.tl3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/013/maze.tl b/tests/013/maze.tl
index f65bc9e0..5cb989d6 100644
--- a/tests/013/maze.tl
+++ b/tests/013/maze.tl
@@ -13,7 +13,8 @@
(if list [list (rand (length list))]))
(defun neigh (loc)
- (tree-bind (x . y) loc
+ (let ((x (from loc))
+ (y (to loc)))
(list (- x 1)..y (+ x 1)..y
x..(- y 1) x..(+ y 1))))