Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix +-reader
  • Loading branch information
g000001 committed Feb 19, 2020
1 parent 7be9f89 commit f907e25
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions readtable.lisp
Expand Up @@ -3,9 +3,10 @@


(cl:eval-when (:compile-toplevel :load-toplevel :execute)
(cl:defvar *srfi-169-syntax* (cl:copy-readtable () ))
(cl:defvar *srfi-169-syntax* (cl:copy-readtable #f))

(let ((cl:*readtable* *srfi-169-syntax*))
(let ((cl:*readtable* *srfi-169-syntax*)
(stdrt (cl:copy-readtable #f)))
(cl:flet ((setmc (c)
(cl:set-macro-character
c
Expand All @@ -14,6 +15,20 @@
(let ((cl:*standard-input* stm))
(read-number)))
#t))
(set+- (c)
(cl:set-macro-character
c
(lambda (stm chr)
(let ((cl:*standard-input* stm))
(cond ((cl:find (peek-char) "0123456789")
(if (cl:eql #\- chr)
(cl:- (read-number))
(read-number)))
(else
(cl:unread-char chr stm)
(let ((cl:*readtable* stdrt))
(read))))))
#t))
(setdmc (c)
(cl:set-dispatch-macro-character
#\# c
Expand All @@ -23,7 +38,8 @@
(cl:unread-char #\# stm)
(let ((cl:*standard-input* stm))
(read-number))))))
(cl:map #f #'setmc "+-0123456789")
(cl:map #f #'setmc "0123456789")
(cl:map #f #'set+- "+-")
(cl:map #f #'setdmc "bodx")))
(cl:defconstant srfi-169-syntax *srfi-169-syntax*))

Expand Down

0 comments on commit f907e25

Please sign in to comment.