Issue #112: Allow reader to recognize inf and nan

This commit is contained in:
Justin Ethier 2016-10-24 00:24:16 +00:00
parent c71163fcf9
commit 7b1e3ce5f7
2 changed files with 12 additions and 1 deletions

View file

@ -3,6 +3,10 @@
TODO: more performance improvements TODO: more performance improvements
TODO: SRFI 113 TODO: SRFI 113
Features:
- Allow the reader to recognize `+inf.0`, `-inf.0`, `+nan.0`, and `-nan.0`.
Bug Fixes Bug Fixes
- Only throw a divide by zero error for integer division. Floating point divide by zero is allowed and evaluates to `nan`. - Only throw a divide by zero error for integer division. Floating point divide by zero is allowed and evaluates to `nan`.

View file

@ -532,7 +532,14 @@
(define (parse-atom a) (define (parse-atom a)
(if (token-numeric? a) (if (token-numeric? a)
(string->number (list->string a)) (string->number (list->string a))
(string->symbol (list->string a)))) (let ((atom (string->symbol (list->string a))))
(if (or (eq? atom '+inf.0)
(eq? atom '-inf.0))
(expt 2 1000000)
(if (or (eq? atom '+nan.0)
(eq? atom '-nan.0))
(/ 0.0 0.0)
atom)))))
;;;;; ;;;;;
;; Read next character from port, using buffered char if available ;; Read next character from port, using buffered char if available