mirror of
https://github.com/kanaka/mal.git
synced 2024-09-20 01:57:09 +03:00
parent
6f8a5d05fb
commit
81eabb9986
@ -58,6 +58,7 @@
|
||||
(else (lp (cddr next) (cons (car next) k) (cons (cadr next) v))))))
|
||||
(match ast
|
||||
((? (lambda (x) (not (list? x)))) (eval_ast ast env))
|
||||
(() ast)
|
||||
(('def! k v) ((env 'set) k (EVAL v env)))
|
||||
(('let* kvs body)
|
||||
(let* ((new-env (make-Env #:outer env))
|
||||
|
@ -60,6 +60,7 @@
|
||||
((null? (cdr next)) (throw 'mal-error "let*: Invalid binding form" kvs))
|
||||
(else (lp (cddr next) (cons (car next) k) (cons (cadr next) v))))))
|
||||
(match ast
|
||||
(() ast)
|
||||
(('def! k v) ((env 'set) k (EVAL v env)))
|
||||
(('let* kvs body)
|
||||
(let* ((new-env (make-Env #:outer env))
|
||||
|
@ -68,6 +68,7 @@
|
||||
;; If you're Lispy enough, there's no recursive at all while you saw named let loop.
|
||||
(let tco-loop((ast ast) (env env))
|
||||
(match ast
|
||||
(() ast)
|
||||
(('def! k v) ((env 'set) k (EVAL v env)))
|
||||
(('let* kvs body)
|
||||
(let* ((new-env (make-Env #:outer env))
|
||||
|
@ -70,6 +70,7 @@
|
||||
;; If you're Lispy enough, there's no recursive at all while you saw named let loop.
|
||||
(let tco-loop((ast ast) (env env))
|
||||
(match ast
|
||||
(() ast)
|
||||
(('def! k v) ((env 'set) k (EVAL v env)))
|
||||
(('let* kvs body)
|
||||
(let* ((new-env (make-Env #:outer env))
|
||||
|
@ -84,6 +84,7 @@
|
||||
;; If you're Lispy enough, there's no recursive at all while you saw named let loop.
|
||||
(let tco-loop((ast ast) (env env))
|
||||
(match ast
|
||||
(() ast)
|
||||
(('quote obj) obj)
|
||||
(('quasiquote obj) (EVAL (_quasiquote (->list obj)) env))
|
||||
(('def! k v) ((env 'set) k (EVAL v env)))
|
||||
|
@ -54,6 +54,7 @@
|
||||
|
||||
(define (is_macro_call ast env)
|
||||
(and (list? ast)
|
||||
(> (length ast) 0)
|
||||
(and=> (env-check (car ast) env) is-macro?)))
|
||||
|
||||
(define (_macroexpand ast env)
|
||||
@ -91,6 +92,7 @@
|
||||
(let ((ast (_macroexpand ast env)))
|
||||
(match ast
|
||||
((? non-list?) (eval_ast ast env))
|
||||
(() ast)
|
||||
(('defmacro! k v)
|
||||
(let ((c (EVAL v env)))
|
||||
(callable-is_macro-set! c #t)
|
||||
|
@ -55,6 +55,7 @@
|
||||
|
||||
(define (is_macro_call ast env)
|
||||
(and (list? ast)
|
||||
(> (length ast) 0)
|
||||
(and=> (env-check (car ast) env) is-macro?)))
|
||||
|
||||
(define (_macroexpand ast env)
|
||||
@ -95,6 +96,7 @@
|
||||
(let ((ast (_macroexpand ast env)))
|
||||
(match ast
|
||||
((? non-list?) (eval_ast ast env))
|
||||
(() ast)
|
||||
(('defmacro! k v)
|
||||
(let ((c (EVAL v env)))
|
||||
(callable-is_macro-set! c #t)
|
||||
|
@ -69,6 +69,7 @@
|
||||
|
||||
(define (is_macro_call ast env)
|
||||
(and (list? ast)
|
||||
(> (length ast) 0)
|
||||
(and=> (env-check (car ast) env) is-macro?)))
|
||||
|
||||
(define (_macroexpand ast env)
|
||||
@ -107,6 +108,7 @@
|
||||
(let ((ast (_macroexpand ast env)))
|
||||
(match ast
|
||||
((? non-list?) (eval_ast ast env))
|
||||
(() ast)
|
||||
(('defmacro! k v)
|
||||
(let ((c (EVAL v env)))
|
||||
(callable-is_macro-set! c #t)
|
||||
|
Loading…
Reference in New Issue
Block a user