don't put chars in parse tree

pull/6/head
Matthew Butterick 7 years ago
parent 954069276d
commit 9aad4b0f24

@ -167,7 +167,6 @@
(let loop ([x (syntax->datum (PARSE x))]) (let loop ([x (syntax->datum (PARSE x))])
(cond (cond
[(list? x) (map loop x)] [(list? x) (map loop x)]
[(char? x) (string x)]
[else x]))) [else x])))
(define PARSE-TREE PARSE-TO-DATUM)))))])) (define PARSE-TREE PARSE-TO-DATUM)))))]))

@ -76,11 +76,9 @@
[(? symbol?) [(? symbol?)
(lookup next-token next-token start end)] (lookup next-token next-token start end)]
[(? string?) [(or (? string?) (? char?))
(lookup (string->symbol next-token) next-token start end)] (define next-token-str (format "~a" next-token))
(lookup (string->symbol next-token-str) next-token-str start end)]
[(? char?)
(lookup (string->symbol (string next-token)) next-token start end)]
;; Compatibility ;; Compatibility
[(? lex:token?) [(? lex:token?)

@ -6,25 +6,25 @@
(check-equal? (syntax->datum (parse "")) (check-equal? (syntax->datum (parse ""))
'(equal)) '(equal))
(check-equal? (syntax->datum (parse "01")) (check-equal? (syntax->datum (parse "01"))
'(equal (zero (equal) #\0) '(equal (zero (equal) "0")
(one (equal) #\1))) (one (equal) "1")))
(check-equal? (syntax->datum (parse "10")) (check-equal? (syntax->datum (parse "10"))
'(equal (one (equal) #\1) '(equal (one (equal) "1")
(zero (equal) #\0))) (zero (equal) "0")))
(check-equal? (syntax->datum (parse "0011")) (check-equal? (syntax->datum (parse "0011"))
'(equal (zero (equal) #\0) '(equal (zero (equal) "0")
(one (equal (zero (equal) #\0) (one (equal (zero (equal) "0")
(one (equal) #\1)) (one (equal) "1"))
#\1))) "1")))
(check-equal? (syntax->datum (parse "0110")) (check-equal? (syntax->datum (parse "0110"))
'(equal (one (equal (zero (equal) #\0) '(equal (one (equal (zero (equal) "0")
(one (equal) #\1)) (one (equal) "1"))
#\1) "1")
(zero (equal) #\0))) (zero (equal) "0")))
(check-equal? (syntax->datum (parse "1100")) (check-equal? (syntax->datum (parse "1100"))
'(equal (one (equal) #\1) '(equal (one (equal) "1")
(zero (equal (one (equal) #\1) (zero (equal (one (equal) "1")
(zero (equal) #\0)) (zero (equal) "0"))
#\0))) "0")))

@ -16,4 +16,12 @@
(check-equal? (check-equal?
(syntax->datum (syntax->datum
(parse "[[[{}]],[],[[{}]]]")) (parse "[[[{}]],[],[[{}]]]"))
'(json (array #\[ (json (array #\[ (json (array #\[ (json) #\])) #\])) #\, (json (array #\[ #\])) #\, (json (array #\[ (json (array #\[ (json) #\])) #\])) #\]))) '(json
(array
"["
(json (array "[" (json (array "[" (json) "]")) "]"))
","
(json (array "[" "]"))
","
(json (array "[" (json (array "[" (json) "]")) "]"))
"]")))

@ -18,7 +18,15 @@
(check-equal? (check-equal?
(syntax->datum (syntax->datum
(parse "[[[{}]],[],[[{}]]]")) (parse "[[[{}]],[],[[{}]]]"))
'(json (array #\[ (json (array #\[ (json (array #\[ (json (object #\{ #\})) #\])) #\])) #\, (json (array #\[ #\])) #\, (json (array #\[ (json (array #\[ (json (object #\{ #\})) #\])) #\])) #\]))) '(json
(array
"["
(json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]"))
","
(json (array "[" "]"))
","
(json (array "[" (json (array "[" (json (object "{" "}")) "]")) "]"))
"]")))

Loading…
Cancel
Save