bugfixes #66

Merged
pkulev merged 43 commits from bugfixes into main 2026-10-19 21:14:40 +02:00
Showing only changes of commit f87e9faa8f - Show all commits

View File

@@ -909,24 +909,23 @@
;; It groups to the right, so its else arm is written at ;; It groups to the right, so its else arm is written at
;; `conditional-else', just looser: a chain there stays bare, ;; `conditional-else', just looser: a chain there stays bare,
;; `a ? x : b ? y : z', and an assignment does not. ;; `a ? x : b ? y : z', and an assignment does not.
(define (c-if/expr . args) (define (c-if/expr c p . rest)
(c-maybe-paren '? (apply c-if/expr/aux args))) (c-maybe-paren
'?
(define (c-if/expr/aux c p . rest) (let lp ((c c) (p p) (ls rest))
(let lp ((c c) (p p) (ls rest)) (cond
(cond ((or (eq? c 'else) (eq? c #t))
((or (eq? c 'else) (eq? c #t)) (if (not (null? ls))
(if (not (null? ls)) (error "forms after else clause in IF" c p ls)
(error "forms after else clause in IF" c p ls) (c-expr p)))
(c-expr p))) ((pair? ls)
((pair? ls) (cat (c-in-test (c-expr c)) " ? " (c-expr p) " : "
(cat (c-in-test (c-expr c)) " ? " (c-expr p) " : " (c-with-op 'conditional-else
(c-with-op 'conditional-else (if (pair? (cdr ls))
(if (pair? (cdr ls)) (lp (car ls) (cadr ls) (cddr ls))
(lp (car ls) (cadr ls) (cddr ls)) (lp 'else (car ls) '())))))
(lp 'else (car ls) '()))))) (else
(else (c-or (c-in-test (c-expr c)) (c-expr p)))))))
(c-or (c-in-test (c-expr c)) (c-expr p))))))
(define (c-if . args) (define (c-if . args)
(fmt-if fmt-expression? (fmt-if fmt-expression?