diff --git a/lib/chibi/ast.scm b/lib/chibi/ast.scm index e57e1340..7433f988 100644 --- a/lib/chibi/ast.scm +++ b/lib/chibi/ast.scm @@ -109,6 +109,34 @@ ((opcode? x) (cond ((opcode-name x) => string->symbol) (else x))) (else x))))) +;;> \section{Identifier Macros} + +;;> \procedure{(make-variable-transformer proc)} + +;;> Returns a new procedure wrapping the input procedure \var{proc}. +;;> The returned procedure, if used as a macro transformer procedure, +;;> can expand an instance of \scheme{set!} with its keyword on the +;;> left hand side. + +;;> \macro{(identifier-syntax clauses ...)} + +;;> A high-level form for creating identifier macros. See +;;> \hyperlink["http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_idx_796"]{the R6RS specification.} + +(define-syntax identifier-syntax + (syntax-rules (set!) + ((_ template) + (syntax-rules () + ((_ xs (... ...)) + (template xs (... ...))) + (x template))) + ((_ (id_1 template_1) ((set! id_2 pattern) template_2)) + (make-variable-transformer + (syntax-rules (set!) + ((set! id_2 pattern) template_2) + ((id_1 xs (... ...)) (template_1 xs (... ...))) + (id_1 template_1)))))) + ;;> \section{Types} ;;> All objects have an associated type, and types may have parent diff --git a/lib/chibi/ast.sld b/lib/chibi/ast.sld index 40b99919..ad0367cb 100644 --- a/lib/chibi/ast.sld +++ b/lib/chibi/ast.sld @@ -1,7 +1,8 @@ (define-library (chibi ast) (export - analyze optimize env-cell ast->sexp macroexpand type-of + analyze optimize env-cell ast->sexp macroexpand identifier-syntax + type-of Object Input-Port Output-Port Opcode Procedure Bytecode Macro Env Number Bignum Flonum Integer Complex Char Boolean Symbol String Byte-Vector Vector Pair File-Descriptor diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm index 5eeca5e7..fecf3301 100644 --- a/tests/syntax-tests.scm +++ b/tests/syntax-tests.scm @@ -84,11 +84,11 @@ ;; this could be fixed in theory) (modules (test-begin "identifier syntax") - (define syntax-test-env (environment '(chibi))) + (define syntax-test-env (environment '(chibi) '(chibi ast))) (eval '(define-syntax low-level-id-macro - (er-macro-transformer* + (er-macro-transformer (lambda (expr rename compare) (if (pair? expr) (list (rename 'quote) 'operator) @@ -102,7 +102,7 @@ (eval '(define-syntax low-level-vt (make-variable-transformer - (er-macro-transformer* + (er-macro-transformer (lambda (expr rename compare) (list (rename 'quote) (if (pair? expr)