Fix some srfi-105 parsing errors
authorAndy Wingo <wingo@pobox.com>
Wed, 3 Mar 2021 21:56:58 +0000 (22:56 +0100)
committerAndy Wingo <wingo@pobox.com>
Wed, 3 Mar 2021 21:56:58 +0000 (22:56 +0100)
* module/ice-9/read.scm (%read): Fix parsing errors.

module/ice-9/read.scm

index 639b76af6724a1af8cf2382d11e1244a5d180049..ee39dfd6044d5d65215e9c5761b5da5d83ec00fe 100644 (file)
                (and (pair? ls)
                     (let ((op (car ls))
                           (ls (cdr ls)))
-                      (if (null? ls)
-                          (list op x)
+                      (if (and (pair? ls) (null? (cdr ls)))
+                          (cons* op x ls)
                           (let ((tail (extract-infix-list ls)))
                             (and tail
-                                 (equal? op (car tail))
+                                 (equal? (strip-annotation op)
+                                         (strip-annotation (car tail)))
                                  (cons* op x (cdr tail))))))))))
       (cond
-       ((or (not (eqv? rdelim #\}))) ret) ; Only on {...} lists.
-       ((null? ret) ret)                  ; {} => ()
-       ((null? (cdr ret)) (car ret))      ; {x} => x
-       ((null? (cddr ret)) ret)           ; {x y} => (x y)
+       ((not (eqv? rdelim #\})) ret) ; Only on {...} lists.
+       ((not (pair? ret)) ret)            ; {} => ()
+       ((not (pair? (cdr ret))) (car ret)); {x} => x
+       ((not (pair? (cddr ret))) ret)     ; {x y} => (x y)
        ((extract-infix-list ret))   ; {x + y + ... + z} => (+ x y ... z)
        (else (cons '$nfx$ ret))))   ; {x y . z} => ($nfx$ x y . z)
     (define curly? (eqv? rdelim #\}))