f6d74c247168

Add #! and #; readers
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 03 Dec 2023 17:29:39 -0500
parents 04ad2212b90f
children 09232fd60df5
branches/tags (none)
files src/readtable.lisp

Changes

--- a/src/readtable.lisp	Fri Dec 01 08:55:24 2023 -0500
+++ b/src/readtable.lisp	Sun Dec 03 17:29:39 2023 -0500
@@ -1,4 +1,18 @@
 (in-package :losh.readtable)
 
+
+(defun sharp-semicolon-reader (stream sub-char numarg)
+  (declare (ignore sub-char numarg))
+  (loop :while (read-line stream nil nil))
+  (values))
+
+(defun shebang-reader (stream sub-char numarg)
+  (declare (ignore sub-char numarg))
+  (read-line stream)
+  (values))
+
 (named-readtables:defreadtable losh
-  (:merge :standard losh.hash-tables::hash-table-constructor-syntax))
+  (:merge :standard losh.hash-tables::hash-table-constructor-syntax)
+  (:macro-char #\# :dispatch)
+  (:dispatch-macro-char #\# #\; #'sharp-semicolon-reader)
+  (:dispatch-macro-char #\# #\! #'shebang-reader))