look past comments in a public form's header

This commit is contained in:
2026-09-21 00:56:26 +03:00
parent 05bab57867
commit 1195e5c191
7 changed files with 38 additions and 19 deletions

View File

@@ -142,21 +142,9 @@
;;; Fn processing
(define (strip-fn-header-comments fn-form)
;; Remove comment forms from the function header
;; ([pub|extern] fn name arglist rettype) so the positional accessors
;; below are not shifted. Comments in the body are left in place as
;; ordinary statements and preserved into the generated C.
(let ((header-count (if (memq (car fn-form) '(pub extern)) 5 4)))
;; This always rebuilds the list, so the location has to be carried
;; over explicitly -- otherwise every function loses it
(copy-form-source!
fn-form
(let loop ((form fn-form) (kept 0) (acc (list)))
(cond
((null? form) (reverse acc))
((= kept header-count) (append (reverse acc) form))
((comment-form? (car form)) (loop (cdr form) kept acc))
(else (loop (cdr form) (+ kept 1) (cons (car form) acc))))))))
;; ([pub|extern] fn name arglist rettype)
(strip-header-comments fn-form
(if (memq (car fn-form) '(pub extern)) 5 4)))
(define (process-fn sex-fn-raw acc)
(let* ((sex-fn (strip-fn-header-comments sex-fn-raw))