Skip to content

Commit

Permalink
Try to fix test on Allegro
Browse files Browse the repository at this point in the history
  • Loading branch information
iamFIREcracker committed Jan 13, 2024
1 parent e02a6f6 commit 407bd90
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
16 changes: 14 additions & 2 deletions syntax.lisp
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
(in-package :aoc)

;; If we don't copy the system readtable first, Allregro will fail with
;; the following error:
;;
;; Attempt to set macro in system readtable #<readtable @ #x20115b5a>;
;; copy readtable first.

(eval-when (:compile-toplevel :load-toplevel :execute)
(defvar *custom-readtable* (copy-readtable))
(setq *readtable* *custom-readtable*))

(eval-when (:compile-toplevel :load-toplevel :execute)
(defun opening-braket-reader (stream char)
(declare (ignore char))
Expand All @@ -9,7 +19,8 @@
(,@(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))))
(set-macro-character #\] (get-macro-character #.(char ")" 0))
*custom-readtable*))

#+#:excluded (read (make-string-input-stream "[format t \"Hello, ~a!\" _]"))

Expand All @@ -18,4 +29,5 @@
(declare (ignore sub-char numarg))
(loop :while (read-line stream nil nil))
(values))
(set-dispatch-macro-character #\# #\; #'sharp-semicolon-reader))
(set-dispatch-macro-character #\# #\; #'sharp-semicolon-reader
*custom-readtable*))
23 changes: 22 additions & 1 deletion vendor/cl-classified/vendor/ml/mlsyntax.lisp
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
(in-package "MLUTILS")

;; If we don't copy the system readtable first, Allregro will fail with
;; the following error:
;;
;; Attempt to set macro in system readtable #<readtable @ #x20115b5a>;
;; copy readtable first.

(eval-when (:compile-toplevel :load-toplevel :execute)
(defvar *custom-readtable* (copy-readtable))
(setq *readtable* *custom-readtable*))

(eval-when (:compile-toplevel :load-toplevel :execute)
(defun opening-braket-reader (stream char)
(declare (ignore char))
Expand All @@ -9,4 +19,15 @@
(,@(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))))
(set-macro-character #\] (get-macro-character #.(char ")" 0))
*custom-readtable*))

#+#: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
*custom-readtable*))

0 comments on commit 407bd90

Please sign in to comment.