rebirth: Add `unquote@' alias for `unquote-splicing'

Since we don't have reader support for ",@", this will have to do for now.

* build-aux/bootstrap/rebirth.scm (%quote-maybe): Add `unquote@'.
    Rename from `-quote-maybe'.
  (%sexp-maybe-type): Rename from `-sexp-maybe-type'.
master
Mike Gerwitz 2017-12-11 22:32:32 -05:00
parent f183ccb2b0
commit 0b0003578b
Signed by: mikegerwitz
GPG Key ID: 8C917B7F5DC51BA2
1 changed files with 10 additions and 8 deletions

View File

@ -586,18 +586,19 @@
;; to be lists. So do not do that---always splice lists.
(define (quasiquote-sexp sexp)
;; get type of token at car of pair, unless not a pair
(define (-sexp-maybe-type sexp)
(define (%sexp-maybe-type sexp)
(and (pair? sexp)
(token? (car sexp))
(token-value (car sexp))))
;; recursively process the sexp, handling various types of unquoting
(define (-quote-maybe sexp delim)
(define (%quote-maybe sexp delim)
(if (pair? sexp)
(let* ((item (car sexp))
(rest (cdr sexp))
(type (-sexp-maybe-type item))
(add-delim (not (string=? type "unquote-splicing"))))
(type (%sexp-maybe-type item))
(add-delim (not (or (string=? type "unquote-splicing")
(string=? type "unquote@")))))
(string-append
(case type
;; escape quoting, nest within
@ -606,8 +607,9 @@
(sexp->es (cadr item))))
;; escape quoting, splice list into parent expression
;; (lazy kluge warning)
(("unquote-splicing")
;; (lazy kluge warning), along with an alias for brevity
;; given that we lack the ",@" syntax right now
(("unquote-splicing" "unquote@")
(string-append
"]).concat(" (sexp->es (cadr item)) ").concat(["))
@ -616,14 +618,14 @@
(quasiquote-sexp item))))
;; continue processing this list
(-quote-maybe rest add-delim)))
(%quote-maybe rest add-delim)))
""))
;; tokens fall back to normal quoting
(if (token? sexp)
(quote-sexp sexp)
(string-append
"([" (-quote-maybe sexp #f) "])")))
"([" (%quote-maybe sexp #f) "])")))
;; Function/procedure aliases and special forms