mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-20 14:19:17 +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)
|
(define-library (libs lib2)
|
||||||
;(import (scheme base))
|
(import (scheme base))
|
||||||
(export lib2-hello)
|
(export lib2-hello or)
|
||||||
(begin
|
(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
|
(define lib2-hello
|
||||||
"Hello from library #2")))
|
"Hello from library #2")))
|
||||||
|
|
|
@ -373,7 +373,8 @@
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; This step separates syntactic analysis from execution.
|
;; 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)
|
(define (analyze exp env)
|
||||||
(cond ((self-evaluating? exp)
|
(cond ((self-evaluating? exp)
|
||||||
|
@ -473,10 +474,11 @@
|
||||||
#f)))
|
#f)))
|
||||||
(cond
|
(cond
|
||||||
((macro? var)
|
((macro? var)
|
||||||
; look up symbol in env, and expand if it is a macro
|
;; 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
|
;; Adds some extra overhead into eval, which is not ideal. may need to
|
||||||
; reduce that overhead later...
|
;; reduce that overhead later...
|
||||||
(write (list 'JAE-DEBUG 'expanding exp)) ;; DEBUG-only
|
;;(write (list 'JAE-DEBUG 'expanding exp)) ;; DEBUG-only
|
||||||
|
|
||||||
;; TODO: need to use common rename/compare functions
|
;; TODO: need to use common rename/compare functions
|
||||||
;; instead of fudging them here. maybe keep common
|
;; instead of fudging them here. maybe keep common
|
||||||
;; functions in the macros module and hook into them???
|
;; functions in the macros module and hook into them???
|
||||||
|
|
Loading…
Add table
Reference in a new issue