Commit d57fc61f authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Load named-readtables, define put reader macros in the table when defined

Make antik-base dependent on named-readtables and define the table as
a copy of the standard table. Then in each system where the three
reader functions are defined, set-dispatch-macro-character into the
:antik readtable immediately after the function definition. This way,
each reader macro is available as soon as the underlying definitions
have been made. For the test files that use reader macros, put the
necessary form
(named-readtables:in-readtable :antik)
just below the in-package form.
parent 6aef5d5f
;; Antik system definition
;; Liam Healy 2010-12-24 09:43:28EST antik.asd
;; Time-stamp: <2014-07-16 11:45:49EDT antik-base.asd>
;; Time-stamp: <2014-11-27 16:38:38EST antik-base.asd>
;; Copyright 2011, 2012, 2013, 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -27,7 +27,7 @@
:license "GPL v3"
:serial t
:defsystem-depends-on (#:asdf-system-connections)
:depends-on (#:iterate #:alexandria #:metabang-bind)
:depends-on (#:iterate #:alexandria #:metabang-bind #:named-readtables)
:components
((:module init
:serial t
......@@ -42,7 +42,8 @@
(:module input-output
:serial t
:components
((:file "parameters")
((:file "readtable")
(:file "parameters")
(:file "format-output")
(:file "float")
(:file "matlab")
......
;; Physical dimension system definition
;; Liam Healy
;; Time-stamp: <2014-10-06 23:13:35EDT date-time.asd>
;; Time-stamp: <2014-11-27 16:38:38EST date-time.asd>
;; Copyright 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -42,12 +42,11 @@
(asdf:defsystem-connection #:datime-pqd
:serial t
:requires (#:date-time #:physical-dimension #:named-readtables)
:requires (#:date-time #:physical-dimension)
:components
((:module date-time
:components
((:file "readtable")
(:file "time-interval")
((:file "time-interval")
(:file "relative-time")
(:file "linear-timepoint")
(:file "dtmath")))))
......
;; Read timepoint specifications.
;; Liam Healy, Sat Feb 4 2006 - 12:17
;; Time-stamp: <2014-10-04 22:09:02EDT read-time.lisp>
;; Time-stamp: <2014-11-27 16:44:26EST read-time.lisp>
;; Copyright 2011, 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -312,6 +312,8 @@
;;; Read timepoint with reader macro, e.g. #d1999-03-30T12:33:45.
;;; Is there any way to get this on additional listeners?
;;; (set-dispatch-macro-character #\# #\d read-datime)
(set-dispatch-macro-character
#\# #\d 'read-datime
(named-readtables:find-readtable :antik))
(defparameter *prehistoric* (read-timepoint "1900-01-01T00:00:00"))
;; Functions on grids
;; Liam Healy 2010-06-19 22:25:17EDT functions.lisp
;; Time-stamp: <2014-10-04 22:20:39EDT functions.lisp>
;; Time-stamp: <2014-11-27 16:57:53EST functions.lisp>
;; Copyright 2010, 2011, 2012, 2013, 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -217,7 +217,9 @@
list)))))
;;; Use #m to make the foreign-array
;;; (set-dispatch-macro-character #\# #\m read-grid)
(set-dispatch-macro-character
#\# #\m 'read-grid
(named-readtables:find-readtable :antik))
;;;;****************************************************************************
;;;; Simple math functions
......
;; Read from a table
;; Liam Healy 2010-07-06 12:32:55EDT read.lisp
;; Time-stamp: <2011-08-24 18:12:49EDT read.lisp>
;; Time-stamp: <2014-11-27 16:40:23EST read.lisp>
;;
;; Copyright 2010, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -76,14 +76,14 @@
#|
;;;;; New approach, based on Fare-CSV reader
(defun read-grid (string)
(defun read-grid-csv (string)
(grid:make-simple-grid
:initial-contents
(antik::map-leaf
'read-from-string
(with-input-from-string (s string) (fare-csv:read-csv-stream s)))))
(read-grid
(read-grid-csv
"1.0, 1.0
2.0, 1.414213562373095
3.0, 1.732050807568877
......
;; Define a new readtable
;; Liam Healy 2014-09-28 22:27:28EDT readtable.lisp
;; Time-stamp: <2014-11-27 15:57:42EST readtable.lisp>
;; Time-stamp: <2014-11-27 16:32:40EST readtable.lisp>
;; Copyright 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -23,7 +23,4 @@
(named-readtables:defreadtable :antik
(:merge :standard)
(:macro-char #\# :dispatch)
(:dispatch-macro-char #\# #\_ #'read-physical-dimension-quantity)
(:dispatch-macro-char #\# #\d #'read-datime)
(:dispatch-macro-char #\# #\m #'grid::read-grid))
(:macro-char #\# :dispatch))
;; Objects that represent physical measurements.
;; Liam Healy Wed Mar 6 2002 - 09:04
;; Time-stamp: <2014-10-04 21:54:50EDT physical-quantities.lisp>
;; Time-stamp: <2014-11-27 16:58:10EST physical-quantities.lisp>
;; Copyright 2011, 2012, 2013 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -333,7 +333,9 @@
(scalar-units-p units)))))
;;; Use #_ for physical dimension quantities, e.g. #_90_degree
;;; (set-dispatch-macro-character #\# #\_ read-physical-dimension-quantity)
(set-dispatch-macro-character
#\# #\_ 'read-physical-dimension-quantity
(named-readtables:find-readtable :antik))
(defmethod creation-form ((pq physical-quantity))
(creation-form-readably
......
;; Tests of physical quantities
;; Liam Healy 2011-01-09 17:38:41EST tests.lisp
;; Time-stamp: <2014-10-06 22:39:08EDT physical-quantities-grid.lisp>
;; Time-stamp: <2014-11-27 17:31:37EST physical-quantities-grid.lisp>
;; Copyright 2011, 2013, 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -19,6 +19,7 @@
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(in-package :antik)
(named-readtables:in-readtable :antik)
;;; These are all scalar units, i.e., the same units apply to each
;;; element of the array.
......
;; Tests of physical quantities
;; Liam Healy 2011-01-09 17:38:41EST tests.lisp
;; Time-stamp: <2013-11-23 14:41:51EST physical-quantities.lisp>
;; Time-stamp: <2014-11-27 17:31:37EST physical-quantities.lisp>
;; Copyright 2011, 2013 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -19,6 +19,7 @@
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(in-package :antik)
(named-readtables:in-readtable :antik)
(defmethod lisp-unit:numerical-equal
((result1 physical-quantity) (result2 physical-quantity) &rest keys &key test)
......
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