filter out '()s from the tree

This commit is contained in:
2025-06-05 12:15:06 +03:00
parent 46877241d9
commit dd9765bd62

View File

@@ -3,7 +3,9 @@
(chicken string) (chicken string)
fmt fmt
fmt-c fmt-c
getopt-long) getopt-long
srfi-1 ; list routines
)
(define (unkebabify sym) (define (unkebabify sym)
(string->symbol (string->symbol
@@ -63,7 +65,8 @@ If filter-proc returns something other, use it instead of processing the element
(cons (cons
(let ((r (read))) (let ((r (read)))
(when (eof-object? r) (when (eof-object? r)
(return (reverse collect))) (return (filter (lambda (e) (not (null? e)))
(reverse collect))))
(case (car r) (case (car r)
((define) ((define)
(eval r) (eval r)
@@ -76,8 +79,7 @@ If filter-proc returns something other, use it instead of processing the element
(define (emit-c forms) (define (emit-c forms)
(map (lambda (form) (map (lambda (form)
(if (not (null? form)) (fmt #t (c-expr form))
(fmt #t (c-expr form)))
(fmt #t "\n")) (fmt #t "\n"))
forms)) forms))