(define spec-group-sections
  (fn
    (forms source)
    (let
      ((sections (list))
        (current-title "Definitions")
        (current-comment nil)
        (current-defines (list)))
      (for-each
        (fn
          (form)
          (when
            (and (list? form) (> (len form) 1))
            (let
              ((name (spec-form-name form)))
              (when name (append! current-defines {:kind (spec-form-kind form) :name name})))))
        forms)
      (when (not (empty? current-defines)) (append! sections {:defines current-defines :title current-title :comment current-comment}))
      sections)))
