summaryrefslogtreecommitdiff
path: root/Lisp
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-03-04 22:53:28 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-03-04 22:53:28 +0100
commit2bfce24e72cfa7a339b485980925839f769e5224 (patch)
treefb87f706f495a0a35a1999dadbf3e37ccd676cc6 /Lisp
parent6a4a13ab9957b22853f617d08c109ef2b647515e (diff)
Introduce functions to disable the reader syntax extensions.
darcs-hash:bc88fd5b88bc84ccf83caff109762f2813a9b53d
Diffstat (limited to 'Lisp')
-rw-r--r--Lisp/defpackage.lisp2
-rw-r--r--Lisp/reader-syntax.lisp27
2 files changed, 27 insertions, 2 deletions
diff --git a/Lisp/defpackage.lisp b/Lisp/defpackage.lisp
index 17a81c8..eaeae3e 100644
--- a/Lisp/defpackage.lisp
+++ b/Lisp/defpackage.lisp
@@ -25,6 +25,8 @@
#:shutdown-runtime
#:enable-method-syntax
#:enable-objective-c-syntax
+ #:disable-method-syntax
+ #:disable-objective-c-syntax
#:invoke-by-name
#:invoke
#:find-objc-class
diff --git a/Lisp/reader-syntax.lisp b/Lisp/reader-syntax.lisp
index 56ae6db..4263df0 100644
--- a/Lisp/reader-syntax.lisp
+++ b/Lisp/reader-syntax.lisp
@@ -18,6 +18,10 @@
(in-package #:mulk.objective-cl)
+(defvar *method-syntax-macro-chars* (list))
+(defvar *bracket-syntax-macro-chars* (list))
+
+
(defun enable-method-syntax ()
"Install a **reader macro** that makes method calls look nicer.
@@ -66,11 +70,19 @@ __defgeneric__ form has been executed.
__enable-objective-c-syntax__"
+ (push (get-dispatch-macro-character #\# #\/) *method-syntax-macro-chars*)
(set-dispatch-macro-character #\# #\/ #'(lambda (stream char arg)
(declare (ignore char arg))
(read-objective-c-method stream))))
+(defun disable-method-syntax ()
+ "FIXME"
+ (when *method-syntax-macro-chars*
+ (let ((macro-char (pop *method-syntax-macro-chars*)))
+ (set-dispatch-macro-character #\# #\/ macro-char))))
+
+
(defun read-objective-c-method (stream)
(loop for char = (read-char stream nil nil t)
while (or (alphanumericp char)
@@ -85,7 +97,7 @@ __defgeneric__ form has been executed.
(defun install-reader-syntax ()
"This function is deprecated. Use __enable-objective-c-syntax__ instead."
- (enable-reader-syntax))
+ (enable-objective-c-syntax))
(defun enable-objective-c-syntax ()
@@ -199,13 +211,24 @@ conciseness.
__invoke__, __invoke-by-name__, __disable-objective-c-syntax__,
__enable-method-syntax__"
+ (push (cons (get-macro-character #\[)
+ (get-macro-character #\]))
+ *bracket-syntax-macro-chars*)
(set-macro-character #\] (get-macro-character #\)))
-
(set-macro-character #\[ #'(lambda (stream char)
(declare (ignore char))
(parse-objc-call stream))))
+(defun disable-objective-c-syntax ()
+ "FIXME"
+ (when *bracket-syntax-macro-chars*
+ (destructuring-bind (open . close)
+ (pop *bracket-syntax-macro-chars*)
+ (set-macro-character #\[ open)
+ (set-macro-character #\[ close))))
+
+
(defun parse-objc-call (stream)
(let ((*standard-input* stream))
(flet ((read-message-part (buffer)