Skip to content

Commit

Permalink
Support backslashes in atoms
Browse files Browse the repository at this point in the history
  • Loading branch information
shawwn committed Sep 13, 2018
1 parent aedf2fd commit 8e4b97d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bin/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ read_table[""] = function (s) {
while (true) {
var __c3 = peek_char(s);
if (__c3 && (! whitespace[__c3] && ! delimiters[__c3])) {
if (__c3 === "\\") {
__str = __str + read_char(s);
}
__str = __str + read_char(s);
} else {
break;
Expand Down
3 changes: 3 additions & 0 deletions bin/reader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ read_table[""] = function (s)
while true do
local __c3 = peek_char(s)
if __c3 and (not whitespace[__c3] and not delimiters[__c3]) then
if __c3 == "\\" then
__str = __str .. read_char(s)
end
__str = __str .. read_char(s)
else
break
Expand Down
4 changes: 3 additions & 1 deletion reader.l
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
(let c (peek-char s)
(if (and c (and (not (get whitespace c))
(not (get delimiters c))))
(cat! str (read-char s))
(do (when (= c "\\")
(cat! str (read-char s)))
(cat! str (read-char s)))
(break))))
(if (= str "true") true
(= str "false") false
Expand Down
4 changes: 3 additions & 1 deletion test.l
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
(test= 1 (- -1))
(test= "0?" (read "0?"))
(test= "0!" (read "0!"))
(test= "0." (read "0."))))
(test= "0." (read "0."))
(test= "#\\;" (read "#\\;"))
(test= "#\\(" (read "#\\("))))

(define-test read-more
(let read (get reader 'read-string)
Expand Down

0 comments on commit 8e4b97d

Please sign in to comment.