WIP towards unquote-splicing

This commit is contained in:
Justin Ethier 2015-05-29 01:39:26 -04:00
parent 0259ee0429
commit 49d6bc3213
2 changed files with 14 additions and 6 deletions

View file

@ -240,12 +240,18 @@
; back to the buffer ; back to the buffer
;; Read the next expression and wrap it in a quote ;; Read the next expression and wrap it in a quote
(let ((sub (parse fp '() '() #f #f #f 0 ptbl))) (letrec ((sub (parse fp '() '() #f #f #f 0 ptbl))
(define new-toks (next-c (read-char fp))
(unquote-sym (if (equal? next-c #\@) 'unquote-splicing 'unquote))
(new-toks
(add-tok (add-tok
(list 'unquote sub) (list unquote-sym sub)
(get-toks tok toks quotes) (get-toks tok toks quotes)
quotes)) quotes)))
;; Buffer read-ahead char, if unused
(if (not (equal? next-c #\@))
(in-port:set-buf! ptbl next-c))
;; Keep going ;; Keep going
(if all? (if all?
(parse fp '() new-toks all? #f #f parens ptbl) (parse fp '() new-toks all? #f #f parens ptbl)

View file

@ -2,4 +2,6 @@
(scheme read)) (scheme read))
(write `(read ,(+ 1 2 3))) (write `(read ,(+ 1 2 3)))
(write `(read ,(list 1 2 3)))
;(write `(read ,@(list 1 2 3)))