mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
Move identifier-syntax to (chibi ast)
This commit is contained in:
parent
86e8b56289
commit
9a0212efff
3 changed files with 33 additions and 4 deletions
|
@ -109,6 +109,34 @@
|
||||||
((opcode? x) (cond ((opcode-name x) => string->symbol) (else x)))
|
((opcode? x) (cond ((opcode-name x) => string->symbol) (else x)))
|
||||||
(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}
|
;;> \section{Types}
|
||||||
|
|
||||||
;;> All objects have an associated type, and types may have parent
|
;;> All objects have an associated type, and types may have parent
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
(define-library (chibi ast)
|
(define-library (chibi ast)
|
||||||
(export
|
(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
|
Object Input-Port Output-Port Opcode Procedure Bytecode Macro Env
|
||||||
Number Bignum Flonum Integer Complex Char Boolean
|
Number Bignum Flonum Integer Complex Char Boolean
|
||||||
Symbol String Byte-Vector Vector Pair File-Descriptor
|
Symbol String Byte-Vector Vector Pair File-Descriptor
|
||||||
|
|
|
@ -84,11 +84,11 @@
|
||||||
;; this could be fixed in theory)
|
;; this could be fixed in theory)
|
||||||
(modules
|
(modules
|
||||||
(test-begin "identifier syntax")
|
(test-begin "identifier syntax")
|
||||||
(define syntax-test-env (environment '(chibi)))
|
(define syntax-test-env (environment '(chibi) '(chibi ast)))
|
||||||
|
|
||||||
(eval
|
(eval
|
||||||
'(define-syntax low-level-id-macro
|
'(define-syntax low-level-id-macro
|
||||||
(er-macro-transformer*
|
(er-macro-transformer
|
||||||
(lambda (expr rename compare)
|
(lambda (expr rename compare)
|
||||||
(if (pair? expr)
|
(if (pair? expr)
|
||||||
(list (rename 'quote) 'operator)
|
(list (rename 'quote) 'operator)
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
(eval
|
(eval
|
||||||
'(define-syntax low-level-vt
|
'(define-syntax low-level-vt
|
||||||
(make-variable-transformer
|
(make-variable-transformer
|
||||||
(er-macro-transformer*
|
(er-macro-transformer
|
||||||
(lambda (expr rename compare)
|
(lambda (expr rename compare)
|
||||||
(list (rename 'quote)
|
(list (rename 'quote)
|
||||||
(if (pair? expr)
|
(if (pair? expr)
|
||||||
|
|
Loading…
Add table
Reference in a new issue