alexp1.scm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ;; A snippet extracted from "alexpander.scm".
  2. ;; This is a best for GitLab issues #11:
  3. ;; "attempting to push dead variable" error on loading Alexpander
  4. (let ()
  5. (define (expand-any sexp store ek sk dk-ea) ;D/377/fl:40084; L62/fl:1
  6. (define (handle-syntax-use syntax head) ;L/72/fl:b
  7. (if (symbol? syntax)
  8. (dk-ea syntax sexp store 0)
  9. sexp))
  10. (cond ((symbol? sexp)
  11. (sk (cdr (assv sexp store)) sexp))
  12. (else
  13. (expand-any (car sexp) store
  14. #t handle-syntax-use #f))))
  15. (define (expand-val sexp store k-ev)
  16. (expand-any sexp store
  17. (lambda (output)
  18. (k-ev store output))
  19. (lambda (syn) (k-ev syn store))
  20. list))
  21. (define (dk-et builtin sexp store loc-n)
  22. (expand-val
  23. sexp
  24. store
  25. (lambda (val store) loc-n)))
  26. (define builtins-store '((define-syntax . define-syntax)))
  27. (define null-prog-1
  28. '(define-syntax letrec-syntax
  29. (let-syntax ((let-syntax let-syntax) (define-syntax define-syntax))
  30. (syntax-rules ()
  31. ((_ ((kw init) ...) . body)
  32. (let-syntax ()
  33. (define-syntax kw init) ... (let-syntax () . body)))))))
  34. (define null-stuff (expand-any null-prog-1 builtins-store #f #f dk-et))
  35. (write (equal? (format #f "~a" null-stuff) "(define-syntax (define-syntax letrec-syntax (let-syntax ((let-syntax let-syntax) (define-syntax define-syntax)) (syntax-rules () ((_ ((kw init) ...) . body) (let-syntax () (define-syntax kw init) ... (let-syntax () . body)))))) ((define-syntax . define-syntax)) 0)"))
  36. (newline)
  37. ;; Output: #t
  38. )