Added define and set! cases to the macro expander.
authorTim Vaughan <tgvaughan@gmail.com>
Mon, 12 Jun 2017 11:33:27 +0000 (23:33 +1200)
committerTim Vaughan <tgvaughan@gmail.com>
Mon, 12 Jun 2017 20:53:37 +0000 (08:53 +1200)
src/scheme-derived-forms.scm
src/scheme.4th

index 1edd186..010519d 100644 (file)
@@ -7,3 +7,8 @@
               (if (pair? args)
                 `(define ,(car args) (lambda ,(cdr args) ,@body))
                 'no-match))
+
+;; Macro expansion test code
+
+(define-macro (test)
+              '(begin (display "Hello!") (newline)))
index 8d361fc..67b656c 100644 (file)
@@ -1783,10 +1783,30 @@ defer expand
     R> drop ['] expand goto-deferred
 ;
 
+: expand-definition ( exp -- result )
+    define-symbol 2swap
+
+    2dup definition-var
+    2swap definition-val expand
+    nil ( define var val' nil )
+
+    cons cons cons ;
+
+: expand-assignment ( exp -- result )
+    set!-symbol 2swap
+
+    2dup assignment-var
+    2swap assignment-val expand
+    nil ( define var val' nil )
+
+    cons cons cons ;
+
 :noname ( exp -- result )
 
     expand-macro
 
+    quote? if exit then
+
     quasiquote? if expand-quasiquote exit then
 
     definition? if expand-definition exit then