diff --git a/docs/lang.rst b/docs/lang.rst index 6a68fed7..9c4152ff 100644 --- a/docs/lang.rst +++ b/docs/lang.rst @@ -58,7 +58,7 @@ section status comments 5.3.1 Top level definitions yes 5.3.2 Internal definitions yes TODO: interreferential definitions 5.3.3 Multiple-value definitions yes -5.4 Syntax definitions yes TODO: internal macro definition is not supported. +5.4 Syntax definitions yes 5.5 Recored-type definitions yes 5.6.1 Library Syntax incomplete In picrin, libraries can be reopend and can be nested. 5.6.2 Library example N/A diff --git a/piclib/built-in.scm b/piclib/built-in.scm index 8221653e..c3c09059 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -292,6 +292,17 @@ `(,(r 'begin) ,@(cdar clauses))) ,(loop (cdr clauses)))))))))) + (define-syntax letrec-syntax + (er-macro-transformer + (lambda (form r c) + (let ((formal (car (cdr form))) + (body (cdr (cdr form)))) + `(let () + ,@(map (lambda (x) + `(,(r 'define-syntax) ,(car x) ,(cadr x))) + formal) + ,@body))))) + (define-syntax syntax-error (er-macro-transformer (lambda (expr rename compare) @@ -317,6 +328,7 @@ and or cond case else => do when unless + letrec-syntax _ ... syntax-error)) @@ -629,6 +641,7 @@ and or cond case else => do when unless + letrec-syntax _ ... syntax-error) (export let-values