|
45 | 45 | (defvar core:*read-hook*) |
46 | 46 | (defvar core:*read-preserving-whitespace-hook*) |
47 | 47 |
|
48 | | - |
49 | | -;;; to avoid that cl:*readtable* and eclector.readtable:*readtable* get out of sync |
50 | 48 | ;;; to avoid eclector.parse-result::*stack* being unbound, when *client* is bound to a parse-result-client |
51 | 49 | ;;; Not sure whether this a a fortunate design in eclector |
52 | 50 |
|
|
62 | 60 | (let ((cl:*readtable* value)) |
63 | 61 | (funcall thunk))) |
64 | 62 |
|
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)) |
82 | 67 | (let ((eclector.reader:*client* *clasp-normal-eclector-client*)) |
83 | 68 | (eclector.reader:read input-stream eof-error-p eof-value recursive-p))) |
84 | 69 |
|
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)) |
91 | 75 | (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))) |
95 | 78 |
|
96 | 79 | (defun cl:read-from-string (string |
97 | 80 | &optional (eof-error-p t) eof-value |
98 | 81 | &key (start 0) (end (length string)) |
99 | 82 | preserve-whitespace) |
100 | 83 | (let ((eclector.reader:*client* *clasp-normal-eclector-client*)) |
101 | 84 | (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))) |
103 | 87 |
|
104 | 88 | ;;; Fixed in https://github.com/s-expressionists/Eclector/commit/19d2d903bb04e3e59ff0557051e134e8ee6195c7 |
105 | 89 | (defun cl:read-delimited-list (char &optional (input-stream *standard-input*) recursive-p) |
|
109 | 93 | (defun core::set-eclector-reader-readmacros (readtable) |
110 | 94 | (eclector.reader::set-standard-macro-characters readtable) |
111 | 95 | (eclector.reader::set-standard-dispatch-macro-characters readtable) |
112 | | - (cl:set-dispatch-macro-character #\# #\a 'core:sharp-a-reader readtable) |
113 | 96 | (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)) |
121 | 98 |
|
122 | 99 | (defun init-clasp-as-eclector-reader () |
123 | 100 | (core::set-eclector-reader-readmacros cl:*readtable*) |
124 | 101 | (core::set-eclector-reader-readmacros (symbol-value 'core:+standard-readtable+)) |
125 | 102 | ;;; also change read |
126 | 103 | ;;; 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)) |
129 | 106 |
|
130 | 107 | (eclector.readtable::init-clasp-as-eclector-reader) |
131 | 108 |
|
|
0 commit comments