Skip to content

Commit

Permalink
add raw string syntax-extension to unit tests #321
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Mar 26, 2024
1 parent 1474957 commit 26e80a0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@

(unset-special! "#nil")

(set-special! "$" 'raw-string lips.specials.SYMBOL)

(define (raw-string)
(if (char=? (peek-char) #\")
(begin
(read-char)
(let loop ((result (vector)) (char (peek-char)))
(read-char)
(if (char=? char #\")
(apply string (vector->list result))
(loop (vector-append result (vector char)) (peek-char)))))))

(define parser/t9 $"foo \ bar")

(unset-special! "$")

(test "parser: #!fold-case"
(lambda (t)
(define foo 10)
Expand All @@ -75,7 +91,8 @@
(t.is parser/t5 ':foo)
(t.is parser/t6 27)
(t.is parser/t7 '(let ((x 3)) (let ((.x x)) (* .x .x .x))))
(t.is parser/t8 '(() () () () ()))))
(t.is parser/t8 '(() () () () ()))
(t.is parser/t9 "foo \\ bar")))

(test "parser: escape hex literals"
(lambda (t)
Expand Down

0 comments on commit 26e80a0

Please sign in to comment.