diff --git a/syntax.lisp b/syntax.lisp index 43d0b7a..534ca35 100644 --- a/syntax.lisp +++ b/syntax.lisp @@ -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 #; +;; 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)) @@ -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!\" _]")) @@ -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*)) diff --git a/vendor/cl-classified/vendor/ml/mlsyntax.lisp b/vendor/cl-classified/vendor/ml/mlsyntax.lisp index ab4b622..479e7ac 100644 --- a/vendor/cl-classified/vendor/ml/mlsyntax.lisp +++ b/vendor/cl-classified/vendor/ml/mlsyntax.lisp @@ -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 #; +;; 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)) @@ -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*))