[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] [PATCH] Allow "unsetting" read syntax
From: |
Felix |
Subject: |
[Chicken-hackers] [PATCH] Allow "unsetting" read syntax |
Date: |
Sun, 28 Oct 2012 09:11:48 -0400 (EDT) |
This patch allows removing read-syntax installed with "set-read-syntax!"
and related procedures.
Fixes bug #940.
cheers,
felix
>From 08980cda014d51f3d06e5adc18d19f51f4bf5fb1 Mon Sep 17 00:00:00 2001
From: felix <address@hidden>
Date: Sun, 28 Oct 2012 13:47:20 +0100
Subject: [PATCH] allow unsetting read-syntax
---
library.scm | 8 ++++++--
manual/Unit library | 4 ++++
types.db | 11 ++++++++---
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/library.scm b/library.scm
index 680687f..f884591 100644
--- a/library.scm
+++ b/library.scm
@@ -3065,9 +3065,13 @@ EOF
(unless (##sys#slot crt slot)
(##sys#setslot crt slot (##sys#make-vector 256 #f)) )
(##sys#check-char chr loc)
- (let ([i (char->integer chr)])
+ (let ((i (char->integer chr)))
(##sys#check-range i 0 256 loc)
- (##sys#setslot (##sys#slot crt slot) i (wrap proc)) ) ) ) ) )
+ (cond (proc
+ (##sys#check-closure proc loc)
+ (##sys#setslot (##sys#slot crt slot) i (wrap proc)))
+ (else
+ (##sys#setslot (##sys#slot crt slot) i #f))))))))
(set! set-read-syntax!
(syntax-setter
diff --git a/manual/Unit library b/manual/Unit library
index 2bc1045..232d42c 100644
--- a/manual/Unit library
+++ b/manual/Unit library
@@ -1224,6 +1224,8 @@ To disable built-in read-syntax, define a handler that
triggers an error (for ex
Similar to {{set-read-syntax!}}, but allows defining new {{#<CHAR> ...}}
reader syntax.
If the first argument is a symbol, then this procedure is equivalent to
{{set-read-syntax!}}.
+{{PROC}} may be {{#f}} to disable previously defined "sharp" read syntax.
+
==== set-parameterized-read-syntax!
@@ -1235,6 +1237,8 @@ arguments: the input port and the number preceding
the dispatching character.
If the first argument is a symbol, then this procedure is equivalent to
{{set-read-syntax!}}.
+{{PROC}} may be {{#f}} to disable previously defined parameterized read syntax.
+
==== copy-read-table
diff --git a/types.db b/types.db
index 940c6e0..c116f7c 100644
--- a/types.db
+++ b/types.db
@@ -1034,13 +1034,18 @@
(set-gc-report! (#(procedure #:clean) set-gc-report! (*) undefined))
(set-parameterized-read-syntax!
- (#(procedure #:clean #:enforce) set-parameterized-read-syntax! (char
(procedure (input-port fixnum) . *)) undefined))
+ (#(procedure #:clean #:enforce) set-parameterized-read-syntax!
+ (char (or boolean (procedure (input-port fixnum) . *))) undefined))
(set-port-name! (#(procedure #:clean #:enforce) set-port-name! (port string)
undefined)
((port string) (##sys#setslot #(1) '3 #(2))))
-(set-read-syntax! (#(procedure #:clean #:enforce) set-read-syntax! (char
(procedure (input-port) . *)) undefined))
-(set-sharp-read-syntax! (#(procedure #:clean #:enforce) set-sharp-read-syntax!
(char (procedure (input-port) . *)) undefined))
+(set-read-syntax! (#(procedure #:clean #:enforce) set-read-syntax!
+ (char (or boolean (procedure (input-port) . *))) undefined))
+
+(set-sharp-read-syntax! (#(procedure #:clean #:enforce) set-sharp-read-syntax!
+ (char (or boolean (procedure (input-port) . *)))
undefined))
+
(setter (#(procedure #:clean #:enforce) setter (procedure) procedure))
(signal (procedure signal (*) . *))
(signum (#(procedure #:clean #:enforce) signum (number) number))
--
1.7.0.4
- [Chicken-hackers] [PATCH] Allow "unsetting" read syntax,
Felix <=