WIP - macros

This commit is contained in:
Justin Ethier 2015-08-12 22:14:11 -04:00
parent ba664fe93f
commit edd6bf81da
2 changed files with 13 additions and 7 deletions

View file

@ -420,6 +420,8 @@ object Cyc_display(object x, FILE *port)
if (obj_is_char(x)) {fprintf(port, "%c", obj_obj2char(x)); return quote_void;} if (obj_is_char(x)) {fprintf(port, "%c", obj_obj2char(x)); return quote_void;}
switch (type_of(x)) switch (type_of(x))
{case macro_tag: {case macro_tag:
fprintf(port, "<macro %p>",(void *)((closure) x)->fn);
break;
case closure0_tag: case closure0_tag:
case closure1_tag: case closure1_tag:
case closure2_tag: case closure2_tag:

View file

@ -375,13 +375,17 @@
(define (analyze exp) (define (analyze exp)
(cond ((self-evaluating? exp) (cond ((self-evaluating? exp)
(analyze-self-evaluating exp)) (analyze-self-evaluating exp))
((quoted? exp) (analyze-quoted exp)) ((quoted? exp) (analyze-quoted exp))
((quasiquoted? exp) (analyze-quasiquoted exp)) ((quasiquoted? exp) (analyze-quasiquoted exp))
((variable? exp) (analyze-variable exp)) ((variable? exp) (analyze-variable exp))
((assignment? exp) (analyze-assignment exp)) ((assignment? exp) (analyze-assignment exp))
((definition? exp) (analyze-definition exp)) ((definition? exp) (analyze-definition exp))
((if? exp) (analyze-if exp)) ((if? exp) (analyze-if exp))
((lambda? exp) (analyze-lambda exp)) ((lambda? exp) (analyze-lambda exp))
;; Expand macros
((and (pair? exp) (macro? (car exp)))
(write (list 'debug 'macro exp))
(analyze (apply (car exp) (cdr exp))))
;; TODO: ideally, macro system would handle these next three ;; TODO: ideally, macro system would handle these next three
((tagged-list? 'let exp) ((tagged-list? 'let exp)
(let ((vars (map car (cadr exp))) ;(let->bindings exp))) (let ((vars (map car (cadr exp))) ;(let->bindings exp)))