From: Taylor R Campbell Date: Fri, 7 Dec 2018 17:11:07 +0000 (+0000) Subject: Use the parser state, not the value produced, to determine success. X-Git-Tag: mit-scheme-pucked-10.1.7~3^2~29 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=6c5382f7a9db4479f0fa7fb584eb8c6f77a36aa7;p=mit-scheme.git Use the parser state, not the value produced, to determine success. --- diff --git a/src/runtime/numpar.scm b/src/runtime/numpar.scm index dd27fa0f1..d1d2a258c 100644 --- a/src/runtime/numpar.scm +++ b/src/runtime/numpar.scm @@ -132,7 +132,12 @@ USA. #f sign comp)) ((i? char) (and (fix:= start end) - (make-rectangular 0 (if (eq? #\- sign) -1 1)))) + (let ((v (if (eq? #\- sign) -1 1))) + (case comp + ((real) (make-rectangular 0 v)) + ((imag) v) + ((angle) #f) + (else (error "Invalid complex state:" comp)))))) (else #f))))) (define (parse-integer string start end integer exactness radix sign comp) @@ -313,22 +318,29 @@ USA. (cond ((i? char) (and sign (fix:= start+1 end) - (make-rectangular 0 real))) + (case comp + ((real) (make-rectangular 0 real)) + ((imag) real) + ((angle) #f) + (else (error "Invalid complex state:" comp))))) ((not (eq? comp 'real)) #f) ((sign? char) (let ((imaginary (parse-top-level string start end exactness radix 'imag))) - (and (complex? imaginary) - (= 0 (real-part imaginary)) - (make-rectangular real (imag-part imaginary))))) + (and imaginary + (begin + (assert (real? imaginary)) + (make-rectangular real imaginary))))) ((char=? #\@ char) (let ((angle (parse-top-level string start+1 end exactness radix 'angle))) - (and (real? angle) - (make-polar real angle)))) + (and angle + (begin + (assert (real? angle)) + (make-polar real angle))))) (else #f))) (and (not (eq? comp 'imag)) real)))