Added expression sequences to macro expander.
[scheme.forth.jl.git] / src / scheme.4th
index 8d361fc..0722208 100644 (file)
@@ -1757,12 +1757,9 @@ hide env
 defer expand
 
 : expand-quasiquote ;
-: expand-definition ;
-: expand-assignment ;
 : expand-define-macro ;
 : expand-if ;
 : expand-lambda ;
-: expand-begin ;
 : expand-application ;
 
 : expand-macro ( exp -- result )
@@ -1783,10 +1780,51 @@ 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 ;
+
+: expand-sequence ( exp -- res )
+    nil? if exit then
+
+    2dup car expand
+    2swap cdr recurse
+
+    cons ;
+
+: expand-begin ( exp -- res )
+    begin-symbol 2swap
+    begin-actions expand-sequence
+
+    cons ;
+
+: expand-lambda ( exp -- res )
+    lambda-symbol 2swap
+    2dup lambda-parameters
+    2swap lambda-body expand-sequence
+
+    cons cons ;
+
 :noname ( exp -- result )
 
     expand-macro
 
+    quote? if exit then
+
     quasiquote? if expand-quasiquote exit then
 
     definition? if expand-definition exit then