syntax-case.scm 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ;;; syntax-case.scm --- R6RS support for `syntax-case' macros
  2. ;; Copyright (C) 2010 Free Software Foundation, Inc.
  3. ;;
  4. ;; This library is free software; you can redistribute it and/or
  5. ;; modify it under the terms of the GNU Lesser General Public
  6. ;; License as published by the Free Software Foundation; either
  7. ;; version 3 of the License, or (at your option) any later version.
  8. ;;
  9. ;; This library is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. ;; Lesser General Public License for more details.
  13. ;;
  14. ;; You should have received a copy of the GNU Lesser General Public
  15. ;; License along with this library; if not, write to the Free Software
  16. ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. (library (rnrs syntax-case (6))
  18. (export make-variable-transformer
  19. syntax-case
  20. syntax
  21. identifier?
  22. bound-identifier=?
  23. free-identifier=?
  24. syntax->datum
  25. datum->syntax
  26. generate-temporaries
  27. with-syntax
  28. quasisyntax
  29. unsyntax
  30. unsyntax-splicing
  31. syntax-violation)
  32. (import (only (guile) make-variable-transformer
  33. syntax-case
  34. syntax
  35. identifier?
  36. bound-identifier=?
  37. free-identifier=?
  38. syntax->datum
  39. datum->syntax
  40. generate-temporaries
  41. with-syntax
  42. quasisyntax
  43. unsyntax
  44. unsyntax-splicing)
  45. (ice-9 optargs)
  46. (rnrs base (6))
  47. (rnrs conditions (6))
  48. (rnrs exceptions (6))
  49. (rnrs records procedural (6)))
  50. (define* (syntax-violation who message form #:optional subform)
  51. (let* ((conditions (list (make-message-condition message)
  52. (make-syntax-violation form subform)))
  53. (conditions (if who
  54. (cons (make-who-condition who) conditions)
  55. conditions)))
  56. (raise (apply condition conditions))))
  57. )