Starting work on macros
parent
1f9c6d472e
commit
bf860c8529
|
@ -9,6 +9,7 @@ IN: lisp
|
||||||
DEFER: convert-form
|
DEFER: convert-form
|
||||||
DEFER: funcall
|
DEFER: funcall
|
||||||
DEFER: lookup-var
|
DEFER: lookup-var
|
||||||
|
DEFER: lisp-macro?
|
||||||
|
|
||||||
! Functions to convert s-exps to quotations
|
! Functions to convert s-exps to quotations
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
@ -57,17 +58,25 @@ PRIVATE>
|
||||||
: convert-quoted ( s-exp -- quot )
|
: convert-quoted ( s-exp -- quot )
|
||||||
second 1quotation ;
|
second 1quotation ;
|
||||||
|
|
||||||
: convert-list-form ( s-exp -- quot )
|
: form-dispatch ( lisp-symbol -- quot )
|
||||||
dup first dup lisp-symbol?
|
name>>
|
||||||
[ name>>
|
|
||||||
{ { "lambda" [ convert-lambda ] }
|
{ { "lambda" [ convert-lambda ] }
|
||||||
{ "quote" [ convert-quoted ] }
|
{ "quote" [ convert-quoted ] }
|
||||||
{ "if" [ convert-if ] }
|
{ "if" [ convert-if ] }
|
||||||
{ "begin" [ convert-begin ] }
|
{ "begin" [ convert-begin ] }
|
||||||
{ "cond" [ convert-cond ] }
|
{ "cond" [ convert-cond ] }
|
||||||
[ drop convert-general-form ]
|
[ drop convert-general-form ]
|
||||||
} case ]
|
} case ;
|
||||||
[ drop convert-general-form ] if ;
|
|
||||||
|
: macro-expand ( s-exp -- quot )
|
||||||
|
;
|
||||||
|
|
||||||
|
: convert-list-form ( s-exp -- quot )
|
||||||
|
dup first
|
||||||
|
{ { [ dup lisp-macro? ] [ macro-expand ] }
|
||||||
|
{ [ dup lisp-symbol? ] [ form-dispatch ] }
|
||||||
|
[ drop convert-general-form ]
|
||||||
|
} cond ;
|
||||||
|
|
||||||
: convert-form ( lisp-form -- quot )
|
: convert-form ( lisp-form -- quot )
|
||||||
{ { [ dup s-exp? ] [ body>> convert-list-form ] }
|
{ { [ dup s-exp? ] [ body>> convert-list-form ] }
|
||||||
|
|
Loading…
Reference in New Issue