Skip to content

Commit 0fe0cd3

Browse files
committed
Remove some unneeded reader macros and rename some functions
1 parent 59e1085 commit 0fe0cd3

File tree

1 file changed

+16
-39
lines changed

1 file changed

+16
-39
lines changed

src/lisp/kernel/cleavir/activate-clasp-readtables-for-eclector.lisp

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
(defvar core:*read-hook*)
4646
(defvar core:*read-preserving-whitespace-hook*)
4747

48-
49-
;;; to avoid that cl:*readtable* and eclector.readtable:*readtable* get out of sync
5048
;;; to avoid eclector.parse-result::*stack* being unbound, when *client* is bound to a parse-result-client
5149
;;; Not sure whether this a a fortunate design in eclector
5250

@@ -62,44 +60,30 @@
6260
(let ((cl:*readtable* value))
6361
(funcall thunk)))
6462

65-
;;; From eclector macro functions:
66-
;;; So we need a way for readers for lists and vectors to explicitly
67-
;;; allow for backquote and comma, whereas BY DEFAULT, they should not
68-
;;; be allowed. We solve this by introducing two variables:
69-
;;; *BACKQUOTE-ALLOWED-P* and *BACKQUOTE-IN-SUBFORMS-ALLOWED-P*.
70-
;;; Initially the two are TRUE. Whenever READ is called, it binds the
71-
;;; variable *BACKQUOTE-ALLOWED-P* to the value of
72-
;;; *BACKQUOTE-IN-SUBFORMS-ALLOWED-P*, and it binds
73-
;;; *BACKQUOTE-IN-SUBFORMS-ALLOWED-P* to FALSE. If no special action
74-
;;; is taken, when READ is called recursively from a reader macro,
75-
;;; the value of *BACKQUOTE-ALLOWED-P* will be FALSE.
76-
77-
(defun read-with-readtable-synced (&optional
78-
(input-stream *standard-input*)
79-
(eof-error-p t)
80-
(eof-value nil)
81-
(recursive-p nil))
63+
(defun read-with-eclector (&optional (input-stream *standard-input*)
64+
(eof-error-p t)
65+
(eof-value nil)
66+
(recursive-p nil))
8267
(let ((eclector.reader:*client* *clasp-normal-eclector-client*))
8368
(eclector.reader:read input-stream eof-error-p eof-value recursive-p)))
8469

85-
;;; to avoid cl:*readtable* and eclector.readtable:*readtable* get out of sync
86-
(defun read-preserving-whitespace-with-readtable-synced (&optional
87-
(input-stream *standard-input*)
88-
(eof-error-p t)
89-
(eof-value nil)
90-
(recursive-p nil))
70+
(defun read-preserving-whitespace-with-eclector
71+
(&optional (input-stream *standard-input*)
72+
(eof-error-p t)
73+
(eof-value nil)
74+
(recursive-p nil))
9175
(let ((eclector.reader:*client* *clasp-normal-eclector-client*))
92-
(eclector.reader:read-preserving-whitespace input-stream eof-error-p eof-value recursive-p)))
93-
94-
;;; need also sync in clasp-cleavir::cclasp-loop-read-and-compile-file-forms
76+
(eclector.reader:read-preserving-whitespace input-stream eof-error-p
77+
eof-value recursive-p)))
9578

9679
(defun cl:read-from-string (string
9780
&optional (eof-error-p t) eof-value
9881
&key (start 0) (end (length string))
9982
preserve-whitespace)
10083
(let ((eclector.reader:*client* *clasp-normal-eclector-client*))
10184
(eclector.reader:read-from-string string eof-error-p eof-value
102-
:start start :end end :preserve-whitespace preserve-whitespace)))
85+
:start start :end end
86+
:preserve-whitespace preserve-whitespace)))
10387

10488
;;; Fixed in https://github.com/s-expressionists/Eclector/commit/19d2d903bb04e3e59ff0557051e134e8ee6195c7
10589
(defun cl:read-delimited-list (char &optional (input-stream *standard-input*) recursive-p)
@@ -109,23 +93,16 @@
10993
(defun core::set-eclector-reader-readmacros (readtable)
11094
(eclector.reader::set-standard-macro-characters readtable)
11195
(eclector.reader::set-standard-dispatch-macro-characters readtable)
112-
(cl:set-dispatch-macro-character #\# #\a 'core:sharp-a-reader readtable)
11396
(cl:set-dispatch-macro-character #\# #\A 'core:sharp-a-reader readtable)
114-
(cl:set-dispatch-macro-character #\# #\I 'core::read-cxx-object readtable)
115-
;;; see issue https://github.com/s-expressionists/Eclector/issues/59
116-
;;; sharpsign-single-quote/relaxed will be exported, but isn't yet
117-
(cl:set-dispatch-macro-character #\# #\' (if (fboundp 'eclector.reader::sharpsign-single-quote/relaxed)
118-
'eclector.reader::sharpsign-single-quote/relaxed
119-
'eclector.reader::sharpsign-single-quote)
120-
readtable))
97+
(cl:set-dispatch-macro-character #\# #\I 'core::read-cxx-object readtable))
12198

12299
(defun init-clasp-as-eclector-reader ()
123100
(core::set-eclector-reader-readmacros cl:*readtable*)
124101
(core::set-eclector-reader-readmacros (symbol-value 'core:+standard-readtable+))
125102
;;; also change read
126103
;;; read-from-string is overwritten above
127-
(setq core:*read-hook* 'read-with-readtable-synced)
128-
(setq core:*read-preserving-whitespace-hook* 'read-preserving-whitespace-with-readtable-synced))
104+
(setq core:*read-hook* 'read-with-eclector)
105+
(setq core:*read-preserving-whitespace-hook* 'read-preserving-whitespace-with-eclector))
129106

130107
(eclector.readtable::init-clasp-as-eclector-reader)
131108

0 commit comments

Comments
 (0)