mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-11 06:20:23 +02:00
Implemented elisp's or form.
* module/language/elisp/README: Document this. * module/language/elisp/compile-tree-il.scm: Implement or.
This commit is contained in:
parent
a431673924
commit
fdfb36de84
2 changed files with 17 additions and 7 deletions
|
@ -13,7 +13,6 @@ Already implemented:
|
|||
Especially still missing:
|
||||
* other progX forms, will be done in macros
|
||||
* where, unless, will be done in macros
|
||||
* or
|
||||
* while, other loops using macros
|
||||
* catch/throw, unwind-protect
|
||||
* real elisp reader instead of Scheme's
|
||||
|
|
|
@ -35,9 +35,10 @@
|
|||
props))))
|
||||
|
||||
|
||||
; Value to use for Elisp's nil.
|
||||
; Value to use for Elisp's nil and t.
|
||||
|
||||
(define (nil-value loc) (make-const loc #f))
|
||||
(define (t-value loc) (make-const loc #t))
|
||||
|
||||
|
||||
; Compile a symbol expression. This is a variable reference or maybe some
|
||||
|
@ -46,11 +47,9 @@
|
|||
(define (compile-symbol loc sym)
|
||||
(case sym
|
||||
|
||||
((nil)
|
||||
(nil-value loc))
|
||||
((nil) (nil-value loc))
|
||||
|
||||
((t)
|
||||
(make-const loc #t))
|
||||
((t) (t-value loc))
|
||||
|
||||
; FIXME: Use fluids.
|
||||
(else
|
||||
|
@ -102,7 +101,7 @@
|
|||
(make-sequence loc (map compile-expr (cdr cur)))
|
||||
(iterate (cdr tail))))))))
|
||||
|
||||
((and) (nil-value loc))
|
||||
((and) (t-value loc))
|
||||
((and . ,expressions)
|
||||
(let iterate ((tail expressions))
|
||||
(if (null? (cdr tail))
|
||||
|
@ -112,6 +111,18 @@
|
|||
(iterate (cdr tail))
|
||||
(nil-value loc)))))
|
||||
|
||||
((or . ,expressions)
|
||||
(let iterate ((tail expressions))
|
||||
(if (null? tail)
|
||||
(nil-value loc)
|
||||
(let ((var (gensym)))
|
||||
(make-let loc
|
||||
'(condition) `(,var) `(,(compile-expr (car tail)))
|
||||
(make-conditional loc
|
||||
(make-lexical-ref loc 'condition var)
|
||||
(make-lexical-ref loc 'condition var)
|
||||
(iterate (cdr tail))))))))
|
||||
|
||||
(('quote ,val)
|
||||
(make-const loc val))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue