diff options
author | Andy Wingo <wingo@pobox.com> | 2017-03-27 20:38:55 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2017-03-28 19:23:13 +0200 |
commit | eb84c2f2da83cf04214bbacf4b33528ce09a5b1a (patch) | |
tree | 18d022910aaa92e869e54a45261d495f16267595 /module/ice-9/psyntax.scm | |
parent | 64c5cc58fced3092f17639bbbddb46c1bae974c8 (diff) | |
download | guile-eb84c2f2da83cf04214bbacf4b33528ce09a5b1a.tar.gz |
Beginnings of psyntax switch to new syntax objects
* module/ice-9/psyntax.scm: Baby steps towards support of a new
representation of syntax objects.
* module/ice-9/psyntax-pp.scm: Regenerate.
Diffstat (limited to 'module/ice-9/psyntax.scm')
-rw-r--r-- | module/ice-9/psyntax.scm | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm index 567f6065b..678d08b97 100644 --- a/module/ice-9/psyntax.scm +++ b/module/ice-9/psyntax.scm @@ -165,7 +165,12 @@ (eval-when (compile) (set-current-module (resolve-module '(guile)))) -(let () +(let ((syntax? (module-ref (current-module) 'syntax?)) + (make-syntax (module-ref (current-module) 'make-syntax)) + (syntax-expression (module-ref (current-module) 'syntax-expression)) + (syntax-wrap (module-ref (current-module) 'syntax-wrap)) + (syntax-module (module-ref (current-module) 'syntax-module))) + (define-syntax define-expansion-constructors (lambda (x) (syntax-case x () @@ -466,7 +471,25 @@ ;; 'gensym' so that the generated identifier is reproducible. (module-gensym (symbol->string id))) - (define-structure (syntax-object expression wrap module)) + (define (syntax-object? x) + (or (syntax? x) + (and (vector? x) + (= (vector-length x) 4) + (eqv? (vector-ref x 0) 'syntax-object)))) + (define (make-syntax-object expression wrap module) + (vector 'syntax-object expression wrap module)) + (define (syntax-object-expression obj) + (if (syntax? obj) + (syntax-expression obj) + (vector-ref obj 1))) + (define (syntax-object-wrap obj) + (if (syntax? obj) + (syntax-wrap obj) + (vector-ref obj 2))) + (define (syntax-object-module obj) + (if (syntax? obj) + (syntax-module obj) + (vector-ref obj 3))) (define-syntax no-source (identifier-syntax #f)) |