diff --git a/reader.scm b/reader.scm index f1e15fe..af80679 100644 --- a/reader.scm +++ b/reader.scm @@ -445,10 +445,15 @@ ("delete" . #\delete) ("escape" . #\escape) ("alarm" . #\alarm) ("backspace" . #\backspace))) +;;; A char is C's, one byte: #\λ was a multi-character constant, whose +;;; value is the C compiler's to choose (define (read-char-lit port) (let ((first (get-ch port))) (when (eof-object? first) (error "Unexpected end of input in character literal")) + (when (> (char->integer first) 127) + (error "a char is one byte, and this is not: write its code point, or a string" + first)) (if (char-alphabetic? first) (let ((rest (read-atom-string port))) (if (string=? rest "") diff --git a/tests/reader.scm b/tests/reader.scm index 86412a6..dde7bbe 100644 --- a/tests/reader.scm +++ b/tests/reader.scm @@ -115,6 +115,14 @@ (test "a surrogate is no character" "no character has this code point" (read-error "\"\\uD800\"")) + ;; A char is C's, one byte, and #\λ came out a multi-character + ;; constant whose value is the compiler's to choose + (test "a char is one byte" + "a char is one byte, and this is not: write its code point, or a string" + (read-error "#\\λ")) + (test "Latin-1 is no exception" #t (string? (read-error "#\\é"))) + (reader-test '(#\a #\~ #\space) "#\\a #\\~ #\\space") + ;; `;' comments are preserved as (comment "...") forms (reader-test '((comment " hi")) "; hi") (reader-test '((comment ";; Prototypes")) ";;; Prototypes")