Skip to content

Commit

Permalink
Merge pull request #159 from orodley/sharpsign-vertical-bar
Browse files Browse the repository at this point in the history
Implement the sharpsign vertical bar reader macro.
  • Loading branch information
davazp committed Jul 15, 2014
2 parents e049b2d + 9dc4723 commit a81d12b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/read.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,16 @@
(push (subseq descriptor start) subdescriptors)
`(oget *root* ,@(reverse subdescriptors)))
(push (subseq descriptor start end) subdescriptors))))
(#\|
(labels ((read-til-bar-sharpsign ()
(do ((ch (%read-char stream) (%read-char stream)))
((and (char= ch #\|) (char= (%peek-char stream) #\#))
(%read-char stream))
(when (and (char= ch #\#) (char= (%peek-char stream) #\|))
(%read-char stream)
(read-til-bar-sharpsign)))))
(read-til-bar-sharpsign)
(ls-read stream eof-error-p eof-value t)))
(otherwise
(cond
((and ch (digit-char-p ch))
Expand Down
6 changes: 6 additions & 0 deletions tests/read.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@
(eql (nth 3 x) 5)
(eq (nth 4 x) (nth 2 x)))))

; SHARPSIGN VERTICAL-BAR
(test (= (read-from-string "#||# 2") 2))
(test (= (read-from-string "#||#2") 2))
(test (= (read-from-string "#| #| |# |# 2") 2))
(test (= (read-from-string "#|#$#%^&*&|# 2") 2))
(test (= (read-from-string "#|||# 2") 2))

0 comments on commit a81d12b

Please sign in to comment.