re-implement macro-expansion using new semantic walker
This commit is contained in:
@@ -23,12 +23,31 @@
|
||||
(test '(pub fn float sum ((int a) (int b))) (sex-fn-prototype sum-fn))
|
||||
(test '((return (cast float (+ a b)))) (sex-fn-body sum-fn))
|
||||
|
||||
(define sex-code
|
||||
'((defmacro (sum-var name a b c)
|
||||
`(var ,name ,(+ a b c)))
|
||||
(let ((sex-code
|
||||
'((defmacro (sum-var name a b c)
|
||||
`(var ,name ,(+ a b c)))
|
||||
|
||||
(sum-var v 1 2 3)))
|
||||
(sum-var v 1 2 3))))
|
||||
|
||||
(test '((var v 6)) (semen-process sex-code))
|
||||
(test '((var v 6)) (semen-process sex-code)))
|
||||
|
||||
;;; Macro expansion
|
||||
|
||||
(test 'a (semen-walk-form 'a identity))
|
||||
(test '(a b c) (semen-walk-form '(a b c) identity))
|
||||
|
||||
(test 'a (semen-macro-expand 'a))
|
||||
(test '(a b c) (semen-macro-expand '(a b c)))
|
||||
|
||||
(let ((sex-code-macro
|
||||
'((defmacro (x10 a)
|
||||
`(* 10 ,a))
|
||||
|
||||
(fn void foo ((int a) (int b))
|
||||
(return (+ a (x10 b)))))))
|
||||
|
||||
(test '((fn void foo ((int a) (int b))
|
||||
(return (+ a (* 10 b)))))
|
||||
(semen-process sex-code-macro)))
|
||||
|
||||
(test-end)
|
||||
|
||||
Reference in New Issue
Block a user