diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d7355e5..fba3ac54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Next Release - Date TBD TODO: SRFI 113 +Features: + +- Allow the reader to recognize `#true` and `#false`. + # 0.3.2 - November 22, 2016 Features: diff --git a/docs/Scheme-Language-Compliance.md b/docs/Scheme-Language-Compliance.md index f57edf83..41b39f46 100644 --- a/docs/Scheme-Language-Compliance.md +++ b/docs/Scheme-Language-Compliance.md @@ -33,7 +33,7 @@ Section | Status | Comments 5.7 The REPL | Yes | 6.1 Equivalence predicates | Yes | 6.2 Numbers | Partial | Only integers and reals are supported at this time. -6.3 Booleans | Yes | `#true` and `#false` are not recognized by parser. +6.3 Booleans | Yes | 6.4 Pairs and lists | Yes | 6.5 Symbols | Yes | 6.6 Characters | Partial | No unicode support. diff --git a/scheme/read.sld b/scheme/read.sld index f673cead..681428ed 100644 --- a/scheme/read.sld +++ b/scheme/read.sld @@ -344,12 +344,27 @@ ;; Booleans ;; Do not use add-tok below, no need to quote a bool ((eq? #\t next-c) -;; TODO: read in rest of #true if it is there + ;; read in rest of #true if it is there + (when (eq? #\r (peek-char fp)) + (if (not (and (eq? #\r (read-char fp)) + (eq? #\u (read-char fp)) + (eq? #\e (read-char fp)))) + (parse-error "Invalid syntax for boolean true" + (in-port:get-lnum ptbl) + (in-port:get-cnum ptbl)))) (if all? (parse fp '() (cons #t toks) all? #f parens ptbl) #t)) ((eq? #\f next-c) -;; TODO: read in rest of #false if it is there + ;; read in rest of #false if it is there + (when (eq? #\a (peek-char fp)) + (if (not (and (eq? #\a (read-char fp)) + (eq? #\l (read-char fp)) + (eq? #\s (read-char fp)) + (eq? #\e (read-char fp)))) + (parse-error "Invalid syntax for boolean false" + (in-port:get-lnum ptbl) + (in-port:get-cnum ptbl)))) (if all? (parse fp '() (cons #f toks) all? #f parens ptbl) #f))