syntax-rules-data.scm 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ; Copyright (c) 1993-2008 by Richard Kelsey and Jonathan Rees. See file COPYING.
  2. ; These define the format for compiled SYNTAX-RULES patterns and templates,
  3. ; which are the shared data between the compilation and expansion phases.
  4. ;----------------
  5. (define (make-pattern-variable v rank)
  6. (vector 'var v rank))
  7. (define (pattern-variable? x)
  8. (and (vector? x)
  9. (eq? (vector-ref x 0) 'var)))
  10. (define (pattern-variable-name pattern-var) (vector-ref pattern-var 1))
  11. (define (pattern-variable-rank pattern-var) (vector-ref pattern-var 2))
  12. ;----------------
  13. (define (make-ellipsis-form form vars)
  14. (vector 'ellipsis form vars))
  15. (define (ellipsis-form? x)
  16. (and (vector? x)
  17. (eq? (vector-ref x 0) 'ellipsis)))
  18. (define (ellipsis-form-body ellipsis) (vector-ref ellipsis 1))
  19. (define (ellipsis-form-vars ellipsis) (vector-ref ellipsis 2))
  20. ;----------------
  21. ; Because we use vectors for pattern variables and ellipses we need to
  22. ; escape any actual vectors that occur. This isn't as bad as it might
  23. ; seem because vectors in patterns and templates need to be converted
  24. ; to lists in any case.
  25. (define (make-vector-marker contents)
  26. (vector 'vector contents))
  27. (define (vector-marker? x)
  28. (and (vector? x)
  29. (eq? (vector-ref x 0) 'vector)))
  30. (define (vector-marker-contents vector-marker) (vector-ref vector-marker 1))