Skip to content

Commit

Permalink
Use named-readtables
Browse files Browse the repository at this point in the history
  • Loading branch information
iamFIREcracker committed Jan 14, 2024
1 parent e02a6f6 commit 9262392
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 4 additions & 19 deletions syntax.lisp
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions vendor/cl-classified/encrypted.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion vendor/cl-classified/vendor/ml/ml.asd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:author "Matteo Landi <[email protected]>"
:license "MIT"
:serial t
:depends-on ()
:depends-on (#:named-readtables)
:components
(
(:file "mlutils-package")
Expand Down
19 changes: 16 additions & 3 deletions vendor/cl-classified/vendor/ml/mlsyntax.lisp
Original file line number Diff line number Diff line change
@@ -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))

)

0 comments on commit 9262392

Please sign in to comment.