2

I would like to format Scheme code inside Emacs, I'm developing Scheme interpreter and my formatter don't work quite right, so while I'm working on syntax-rules macro I would like to pretty print the code I'm working on, without the need right not to fix my formatter.

The code is expansion of SRFI-197 that I'm try to debug and fix (fix my syntax-rules implementation since the code in SRFI-197 is correct).

Just for completeness here is the code I'm trying to format:

(let () (define-syntax %chain (syntax-rules …₂ (placeholder ellipsis) ((_ () () () ((var) …₂) () (step …₂ last-step)) (let* ((var step) …₂) last-step)) ((_ () () () (vars …₂) () (step …₂ last-step)) (let*-values ((vars step) …₂) last-step)) ((_ () () () out-vars (step . in-steps) out-steps) (%chain step () () out-vars in-steps out-steps)) ((_ () step () (out-vars …₂) in-steps (out-steps …₂)) (%chain () () () (out-vars …₂ ignored) in-steps (out-steps …₂ step))) ((_ () step vars (out-vars …₂) in-steps (out-steps …₂)) (%chain () () () (out-vars …₂ vars) in-steps (out-steps …₂ step))) ((_ (placeholder ellipsis) (step …₂) () (out-vars …₂) in-steps (out-steps …₂)) (%chain () () () (out-vars …₂ chain-rest-var) in-steps (out-steps …₂ (apply step …₂ chain-rest-var)))) ((_ (placeholder ellipsis) (step …₂) (vars …₂) (out-vars …₂) in-steps (out-steps …₂)) (%chain () () () (out-vars …₂ (vars …₂ . chain-rest-var)) in-steps (out-steps …₂ (apply step …₂ chain-rest-var)))) ((_ (placeholder ellipsis . rest) . _) (syntax-error _ ... can only be used as a final argument)) ((_ (placeholder . in-step) (out-step …₂) (vars …₂) . rest) (%chain in-step (out-step …₂ chain-var) (vars …₂ chain-var) . rest)) ((_ (x . in-step) (out-step …₂) . rest) (%chain in-step (out-step …₂ x) . rest)))) (%chain (map (lambda (x) (+ x 1)) _) () () () ((filter odd? _) (fold * 1 _)) (initial-value)))

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.