This commit is contained in:
Justin Ethier 2015-05-27 22:55:48 -04:00
parent 9bded8918b
commit 12b27ee8f5

View file

@ -41,15 +41,16 @@
;; Helper functions ;; Helper functions
(define (add-tok tok toks quotes) (define (add-tok tok toks quotes)
(define (loop i) ; TODO: all this code is obsolete, get rid of it and the 'quotes' parameters
(if (= quotes i) ;(define (loop i)
tok ; (if (= quotes i)
(cons 'quote (cons (loop (+ i 1)) '())))) ; tok
(if quotes ; (cons 'quote (cons (loop (+ i 1)) '()))))
(cons ;(if quotes
(loop 0) ; (cons
toks) ; (loop 0)
(cons tok toks))) ; toks)
(cons tok toks));)
;; Get completed list of tokens ;; Get completed list of tokens
(define (get-toks tok toks quotes) (define (get-toks tok toks quotes)
@ -172,22 +173,7 @@
(in-port:set-buf! ptbl c) (in-port:set-buf! ptbl c)
(car (add-tok (->tok tok) toks quotes))) (car (add-tok (->tok tok) toks quotes)))
(else (else
;; OLD CODE: ;; Read the next expression and wrap it in a quote
;; (let ((quote-level (if quotes
;; (+ quotes 1)
;; 1)))
;; (cond
;; ((null? tok)
;; (parse fp '() toks all? comment? quote-level parens ptbl))
;; (else
;; (parse fp '() (add-tok (->tok tok) toks quotes)
;; all? comment? quote-level parens ptbl)))))))
;; New code - seems to be messing up the paren count??
; maybe the code that reads closing parens needs to change such that
; it keeps the closing paren buffered if we are not in "all?" mode.
; (write `(reading quoted subexpr))
; (newline)
(let ((sub (let ((sub
(parse fp (parse fp
'() '()
@ -210,8 +196,7 @@
;; 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)
(car new-toks))) (car new-toks))))))
)))
((eq? c #\() ((eq? c #\()
(cond (cond
((and (not all?) (not (null? tok))) ((and (not all?) (not (null? tok)))