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 0e1dec2 commit ef6b0ab
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 25 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: 1 addition & 1 deletion vendor/cl-classified/classified.asd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:version "0.0.1"

:depends-on (
#:ml
#:net.matteolandi.utils
#:3am

#:cl-base64
Expand Down
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
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))

)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(asdf:defsystem #:ml
(asdf:defsystem #:net.matteolandi.utils
:author "Matteo Landi <[email protected]>"
:license "MIT"
:serial t
:depends-on ()
:depends-on (#:named-readtables)
:components
(
(:file "mlutils-package")
Expand Down

0 comments on commit ef6b0ab

Please sign in to comment.