mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-18 21:29:18 +02:00
WIP
This commit is contained in:
parent
3608c2aeda
commit
7f0c89e2fd
2 changed files with 21 additions and 7 deletions
|
@ -1,6 +1,18 @@
|
|||
(define-library (libs lib2)
|
||||
;(import (scheme base))
|
||||
(export lib2-hello)
|
||||
(import (scheme base))
|
||||
(export lib2-hello or)
|
||||
(begin
|
||||
|
||||
(define-syntax or
|
||||
(er-macro-transformer
|
||||
(lambda (expr rename compare)
|
||||
(cond ((null? (cdr expr)) #f)
|
||||
((null? (cddr expr)) (cadr expr))
|
||||
(else
|
||||
(list (rename 'let) (list (list (rename 'tmp) (cadr expr)))
|
||||
(list (rename 'if) (rename 'tmp)
|
||||
(rename 'tmp)
|
||||
(cons (rename 'or) (cddr expr)))))))))
|
||||
|
||||
(define lib2-hello
|
||||
"Hello from library #2")))
|
||||
|
|
|
@ -373,7 +373,8 @@
|
|||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; This step separates syntactic analysis from execution.
|
||||
;; And environment is passed, but it is only used to expand macros.
|
||||
;; - exp => Code to analyze
|
||||
;; - env => Environment used to expand macros
|
||||
;;
|
||||
(define (analyze exp env)
|
||||
(cond ((self-evaluating? exp)
|
||||
|
@ -473,10 +474,11 @@
|
|||
#f)))
|
||||
(cond
|
||||
((macro? var)
|
||||
; look up symbol in env, and expand if it is a macro
|
||||
; Adds some extra overhead into eval, which is not ideal. may need to
|
||||
; reduce that overhead later...
|
||||
(write (list 'JAE-DEBUG 'expanding exp)) ;; DEBUG-only
|
||||
;; look up symbol in env, and expand if it is a macro
|
||||
;; Adds some extra overhead into eval, which is not ideal. may need to
|
||||
;; reduce that overhead later...
|
||||
;;(write (list 'JAE-DEBUG 'expanding exp)) ;; DEBUG-only
|
||||
|
||||
;; TODO: need to use common rename/compare functions
|
||||
;; instead of fudging them here. maybe keep common
|
||||
;; functions in the macros module and hook into them???
|
||||
|
|
Loading…
Add table
Reference in a new issue