Commit 7f91e263 authored by Liam Healy's avatar Liam Healy

New macro set-reader-in-file

parent 577cfb62
;; Define a new readtable
;; Liam Healy 2014-09-28 22:27:28EDT readtable.lisp
;; Time-stamp: <2015-04-05 22:40:06EDT readtable.lisp>
;; Time-stamp: <2015-04-17 17:44:34EDT readtable.lisp>
;; Copyright 2014, 2015 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -19,7 +19,7 @@
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(in-package :antik)
(export 'set-reader)
(export '(set-reader set-reader-in-file))
(named-readtables:defreadtable :antik
(:merge :standard)
......@@ -27,7 +27,15 @@
(defun set-reader (&optional (readtable t) (default-float 'double-float))
"If readtable is true, set the reader to enable the three Antik reader macros #_ (physical dimension quantity), #d (date/time), #m (grid). Set the reader to interpret float literals without an exponent marker to be the type specified. If nil, leave as-is."
(named-readtables:in-readtable :antik)
(when readtable (named-readtables:in-readtable :antik))
(when default-float
(setf *read-default-float-format* default-float)
#+allegro (tpl:setq-default *read-default-float-format* default-float)))
(defmacro set-reader-in-file (&optional (readtable t) (default-float 'double-float))
"If readtable is true, set the reader to enable the three Antik reader macros #_ (physical dimension quantity), #d (date/time), #m (grid). Set the reader to interpret float literals without an exponent marker to be the type specified. If nil, leave as-is."
`(eval-when (:compile-toplevel :load-toplevel :execute)
,@(when readtable `((named-readtables:in-readtable :antik)))
,@(when default-float
`((setf *read-default-float-format* ',default-float)
#+allegro (tpl:setq-default *read-default-float-format* ,default-float)))))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment