mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 00:37:35 +02:00
WIP - migrating first macros to libraries
This commit is contained in:
parent
82e908d670
commit
9b96d13857
3 changed files with 44 additions and 16 deletions
7
TODO
7
TODO
|
@ -11,6 +11,13 @@ Working TODO list. should start creating issues for these to get them out of her
|
||||||
if necessary, write makefile directive to automate rebuilding cyclone for macro development
|
if necessary, write makefile directive to automate rebuilding cyclone for macro development
|
||||||
|
|
||||||
- macros
|
- macros
|
||||||
|
- tried moving 'and macro from base to trans, and recompiled/reinstalled modules and exec's.
|
||||||
|
seemed to work OK with meta file installed.
|
||||||
|
but without meta file, it seems and is not expanded and cyclone tries to call it
|
||||||
|
directly during execution, which of course segfaults.
|
||||||
|
need to understand why it is not expanded. also double-check but it must have worked
|
||||||
|
fine when meta file was installed, because did not see segfaults at that time.
|
||||||
|
|
||||||
* thought: if we go with meta files, the compiler can revert back
|
* thought: if we go with meta files, the compiler can revert back
|
||||||
to using compiled macros if we do not install the meta files.
|
to using compiled macros if we do not install the meta files.
|
||||||
just an idea, may be a hack or not feasible. not an awful idea to
|
just an idea, may be a hack or not feasible. not an awful idea to
|
||||||
|
|
|
@ -80,11 +80,32 @@
|
||||||
flush-output-port
|
flush-output-port
|
||||||
read-line
|
read-line
|
||||||
features
|
features
|
||||||
|
and
|
||||||
|
or
|
||||||
)
|
)
|
||||||
(begin
|
(begin
|
||||||
;; Features implemented by this Scheme
|
;; Features implemented by this Scheme
|
||||||
(define (features) '(cyclone r7rs exact-closed))
|
(define (features) '(cyclone r7rs exact-closed))
|
||||||
|
|
||||||
|
(define-syntax and
|
||||||
|
(er-macro-transformer
|
||||||
|
(lambda (expr rename compare)
|
||||||
|
(cond ((null? (cdr expr)) #t)
|
||||||
|
((null? (cddr expr)) (cadr expr))
|
||||||
|
(else (list (rename 'if) (cadr expr)
|
||||||
|
(cons (rename 'and) (cddr expr))
|
||||||
|
#f))))))
|
||||||
|
(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)))))))))
|
||||||
|
|
||||||
;; TODO: The whitespace characters are space, tab, line feed, form feed (not in parser yet), and carriage return.
|
;; TODO: The whitespace characters are space, tab, line feed, form feed (not in parser yet), and carriage return.
|
||||||
(define call-with-current-continuation call/cc)
|
(define call-with-current-continuation call/cc)
|
||||||
;; TODO: this is from r7rs, but is not really good enough by itself
|
;; TODO: this is from r7rs, but is not really good enough by itself
|
||||||
|
|
|
@ -139,22 +139,22 @@
|
||||||
(define (get-macros) *defined-macros*)
|
(define (get-macros) *defined-macros*)
|
||||||
(define *defined-macros*
|
(define *defined-macros*
|
||||||
(list
|
(list
|
||||||
(cons 'and
|
; (cons 'and
|
||||||
(lambda (expr rename compare)
|
; (lambda (expr rename compare)
|
||||||
(cond ((null? (cdr expr))) ;; TODO (?): #t)
|
; (cond ((null? (cdr expr))) ;; TODO (?): #t)
|
||||||
((null? (cddr expr)) (cadr expr))
|
; ((null? (cddr expr)) (cadr expr))
|
||||||
(else (list (rename 'if) (cadr expr)
|
; (else (list (rename 'if) (cadr expr)
|
||||||
(cons (rename 'and) (cddr expr))
|
; (cons (rename 'and) (cddr expr))
|
||||||
#f)))))
|
; #f)))))
|
||||||
(cons 'or
|
; (cons 'or
|
||||||
(lambda (expr rename compare)
|
; (lambda (expr rename compare)
|
||||||
(cond ((null? (cdr expr)) #f)
|
; (cond ((null? (cdr expr)) #f)
|
||||||
((null? (cddr expr)) (cadr expr))
|
; ((null? (cddr expr)) (cadr expr))
|
||||||
(else
|
; (else
|
||||||
(list (rename 'let) (list (list (rename 'tmp) (cadr expr)))
|
; (list (rename 'let) (list (list (rename 'tmp) (cadr expr)))
|
||||||
(list (rename 'if) (rename 'tmp)
|
; (list (rename 'if) (rename 'tmp)
|
||||||
(rename 'tmp)
|
; (rename 'tmp)
|
||||||
(cons (rename 'or) (cddr expr))))))))
|
; (cons (rename 'or) (cddr expr))))))))
|
||||||
; (cons 'let (lambda (exp rename compare) (let=>lambda exp)))
|
; (cons 'let (lambda (exp rename compare) (let=>lambda exp)))
|
||||||
(cons 'let
|
(cons 'let
|
||||||
(lambda (expr rename compare)
|
(lambda (expr rename compare)
|
||||||
|
|
Loading…
Add table
Reference in a new issue