From 93f445e3f20c9c92edb44a8e2e8ec93baaff45b1 Mon Sep 17 00:00:00 2001 From: Matteo Landi Date: Sat, 13 Jan 2024 15:29:33 +0100 Subject: [PATCH] Use named-readtables --- Makefile | 8 +++++++ syntax.lisp | 23 ++++--------------- vendor/cl-classified/classified.asd | 2 +- vendor/cl-classified/encrypted.lisp | 2 ++ vendor/cl-classified/vendor/ml/mlsyntax.lisp | 19 ++++++++++++--- .../ml/{ml.asd => net.matteolandi.utils.asd} | 4 ++-- 6 files changed, 33 insertions(+), 25 deletions(-) rename vendor/cl-classified/vendor/ml/{ml.asd => net.matteolandi.utils.asd} (70%) diff --git a/Makefile b/Makefile index 966fa99..34aafbe 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,14 @@ vendor/quickutils.lisp: vendor/quickutil vendor/make-quickutils.lisp cd vendor && sbcl --noinform --load "make-quickutils.lisp" --non-interactive vendor/quickutil: ln -sf ~/Workspace/quickutil vendor/quickutil +cl-classified: + mkdir -p vendor/cl-classified + cp ~/Workspace/cl-encrypted/classified.asd vendor/cl-classified/ + cp ~/Workspace/cl-encrypted/encrypted.lisp vendor/cl-classified/ + cp ~/Workspace/cl-encrypted/vendor/ml/mlsyntax.lisp vendor/cl-classified/vendor/ml/ + cp ~/Workspace/cl-encrypted/vendor/ml/mlutils-package.lisp vendor/cl-classified/vendor/ml/ + cp ~/Workspace/cl-encrypted/vendor/ml/mlutils.lisp vendor/cl-classified/vendor/ml/ + cp ~/Workspace/cl-encrypted/vendor/ml/net.matteolandi.utils.asd vendor/cl-classified/vendor/ml/ # Info ------------------------------------------------------------------------ .PHONY: lisp-info diff --git a/syntax.lisp b/syntax.lisp index 43d0b7a..21c2f45 100644 --- a/syntax.lisp +++ b/syntax.lisp @@ -1,21 +1,6 @@ (in-package :aoc) -(eval-when (:compile-toplevel :load-toplevel :execute) - (defun opening-braket-reader (stream char) - (declare (ignore char)) - (let ((arg (intern "_"))) - `(lambda (&optional ,arg) - (declare (ignorable ,arg)) - (,@(read-delimited-list #\] stream t))))) - (set-macro-character #\[ #'opening-braket-reader) - ; Using #\) messes up with the editor -,- - (set-macro-character #\] (get-macro-character #.(char ")" 0)))) - -#+#:excluded (read (make-string-input-stream "[format t \"Hello, ~a!\" _]")) - -(eval-when (:compile-toplevel :load-toplevel :execute) - (defun sharp-semicolon-reader (stream sub-char numarg) - (declare (ignore sub-char numarg)) - (loop :while (read-line stream nil nil)) - (values)) - (set-dispatch-macro-character #\# #\; #'sharp-semicolon-reader)) +#+running-locally +(handler-bind ((named-readtables:reader-macro-conflict 'continue)) + (named-readtables:merge-readtables-into :current :mlutils-syntax)) +#-running-locally (named-readtables:merge-readtables-into :current :mlutils-syntax) diff --git a/vendor/cl-classified/classified.asd b/vendor/cl-classified/classified.asd index c73420a..3f7636f 100644 --- a/vendor/cl-classified/classified.asd +++ b/vendor/cl-classified/classified.asd @@ -14,7 +14,7 @@ :version "0.0.1" :depends-on ( - #:ml + #:net.matteolandi.utils #:3am #:cl-base64 diff --git a/vendor/cl-classified/encrypted.lisp b/vendor/cl-classified/encrypted.lisp index f873dcf..02e1bfc 100644 --- a/vendor/cl-classified/encrypted.lisp +++ b/vendor/cl-classified/encrypted.lisp @@ -37,6 +37,8 @@ *slot*)) (in-package #:classified) +(named-readtables:in-readtable :mlutils-syntax) + #| # For each entry it generates an accessor exposing the full name DEFAULT_PROPERTIES = { diff --git a/vendor/cl-classified/vendor/ml/mlsyntax.lisp b/vendor/cl-classified/vendor/ml/mlsyntax.lisp index ab4b622..1748e06 100644 --- a/vendor/cl-classified/vendor/ml/mlsyntax.lisp +++ b/vendor/cl-classified/vendor/ml/mlsyntax.lisp @@ -1,12 +1,25 @@ (in-package "MLUTILS") + (eval-when (:compile-toplevel :load-toplevel :execute) + (defun opening-braket-reader (stream char) (declare (ignore char)) (let ((arg (intern "_"))) `(lambda (&optional ,arg) (declare (ignorable ,arg)) (,@(read-delimited-list #\] stream t))))) - (set-macro-character #\[ #'opening-braket-reader) - ; Using #\) messes up with the editor -,- - (set-macro-character #\] (get-macro-character #.(char ")" 0)))) + + (defun sharp-semicolon-reader (stream sub-char numarg) + (declare (ignore sub-char numarg)) + (loop :while (read-line stream nil nil)) + (values)) + + + (named-readtables:defreadtable :mlutils-syntax + (:merge :standard) + (:macro-char #\[ #'opening-braket-reader) + (:macro-char #\] (get-macro-character #\))) + (:dispatch-macro-char #\# #\; #'sharp-semicolon-reader)) + + ) diff --git a/vendor/cl-classified/vendor/ml/ml.asd b/vendor/cl-classified/vendor/ml/net.matteolandi.utils.asd similarity index 70% rename from vendor/cl-classified/vendor/ml/ml.asd rename to vendor/cl-classified/vendor/ml/net.matteolandi.utils.asd index 4621885..18e8044 100644 --- a/vendor/cl-classified/vendor/ml/ml.asd +++ b/vendor/cl-classified/vendor/ml/net.matteolandi.utils.asd @@ -1,8 +1,8 @@ -(asdf:defsystem #:ml +(asdf:defsystem #:net.matteolandi.utils :author "Matteo Landi " :license "MIT" :serial t - :depends-on () + :depends-on (#:named-readtables) :components ( (:file "mlutils-package")