mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Added unquote
This commit is contained in:
parent
a09bf93b5c
commit
82519fdd05
2 changed files with 26 additions and 4 deletions
25
parser.scm
25
parser.scm
|
@ -216,6 +216,31 @@
|
|||
(if all?
|
||||
(parse fp '() new-toks all? #f #f parens ptbl)
|
||||
(car new-toks))))))
|
||||
((eq? c #\,)
|
||||
(cond
|
||||
((and (not all?) (not quotes) (not (null? tok)))
|
||||
;; Reached a terminal char, read out previous token
|
||||
(in-port:set-buf! ptbl c)
|
||||
(car (add-tok (->tok tok) toks quotes)))
|
||||
(else
|
||||
|
||||
;; TODO: this is not good enough for unquote-splicing as
|
||||
;; that construct requires reading two chars ,@
|
||||
;; need a way of peeking at the next char here, either
|
||||
;; via peek-char, or perhaps better by having a larger buffer
|
||||
;; of input chars.
|
||||
|
||||
;; Read the next expression and wrap it in a quote
|
||||
(let ((sub (parse fp '() '() #f #f #f 0 ptbl)))
|
||||
(define new-toks
|
||||
(add-tok
|
||||
(list 'unquote sub)
|
||||
(get-toks tok toks quotes)
|
||||
quotes))
|
||||
;; Keep going
|
||||
(if all?
|
||||
(parse fp '() new-toks all? #f #f parens ptbl)
|
||||
(car new-toks))))))
|
||||
((eq? c #\()
|
||||
(cond
|
||||
((and (not all?) (not (null? tok)))
|
||||
|
|
5
test.scm
5
test.scm
|
@ -1,8 +1,5 @@
|
|||
(import (scheme base)
|
||||
(scheme read))
|
||||
'aa
|
||||
(define (quoted? exp)
|
||||
(tagged-list? exp 'quote))
|
||||
|
||||
(write (read))
|
||||
(write `(read ,(+ 1 2 3)))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue