include.scm 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!r6rs
  2. ;;; include.sls --- `include' macros
  3. ;; Copyright (C) 2010 Andreas Rottmann <a.rottmann@gmx.at>
  4. ;; This program is free software, you can redistribute it and/or
  5. ;; modify it under the terms of the MIT/X11 license.
  6. ;; You should have received a copy of the MIT/X11 license along with
  7. ;; this program. If not, see
  8. ;; <http://www.opensource.org/licenses/mit-license.php>.
  9. ;;; Commentary:
  10. ;;; Code:
  11. (library (arguile lib private include)
  12. (export include-file
  13. include-file/downcase)
  14. (import (rnrs)
  15. (for (arguile lib private include helper) expand)
  16. (for (arguile lib private include compat) expand))
  17. (define-syntax include-file
  18. (lambda (stx)
  19. (syntax-case stx ()
  20. ((k <path>)
  21. (include-file/aux 'include-file #'k (syntax->datum #'<path>) values))
  22. ((k <directory> <file>)
  23. (include-file/aux 'include-file
  24. #'k
  25. (syntax->datum #'(<directory> <file>))
  26. values)))))
  27. (define-syntax include-file/downcase
  28. (lambda (stx)
  29. ;; This loses all the annotations, but Ikarus provides no way to
  30. ;; (re-)construct annotation objects ATM.
  31. (define (downcase thing)
  32. (let ((form (if (annotation? thing)
  33. (annotation-expression thing)
  34. thing)))
  35. (cond ((symbol? form)
  36. (string->symbol (string-downcase (symbol->string form))))
  37. ((pair? form)
  38. (cons (downcase (car form))
  39. (downcase (cdr form))))
  40. (else
  41. thing))))
  42. (syntax-case stx ()
  43. ((k <path>)
  44. (include-file/aux 'include-file #'k (syntax->datum #'<path>) downcase))
  45. ((k <directory> <file>)
  46. (include-file/aux 'include-file
  47. #'k
  48. (syntax->datum #'(<directory> <file>))
  49. downcase)))))
  50. )