Recognize #true and #false

This commit is contained in:
Justin Ethier 2016-11-19 18:37:20 +00:00
parent ae3c0ffefe
commit 17be2dc09a
3 changed files with 22 additions and 3 deletions

View file

@ -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:

View file

@ -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.

View file

@ -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))