Remove comment parsing from Racket implementation

This commit is contained in:
Tony Garnock-Jones 2019-07-01 21:47:12 +01:00
parent 0d0124f004
commit 97cd007bab
1 changed files with 6 additions and 7 deletions

View File

@ -253,10 +253,7 @@
;;---------------------------------------------------------------------------
(define (skip-whitespace* i)
(regexp-match? #px#"^(\\s|,)*" i)
(match (peek-char i)
[#\; (regexp-match? #px#"[^\r\n]*[\r\n]" i) (skip-whitespace* i)]
[_ #t]))
(regexp-match? #px#"^(\\s|,)*" i)) ;; side effect: consumes matched portion of input
(define (parse-error* i fmt . args)
(define-values [line column pos] (port-next-location i))
@ -652,11 +649,11 @@
(cross-check "#\"ABC\"" #"ABC" (#x63 #x41 #x42 #x43))
(cross-check "#hex{414243}" #"ABC" (#x63 #x41 #x42 #x43))
(cross-check "#hex{ 41 4A 4e }" #"AJN" (#x63 #x41 #x4A #x4E))
(cross-check "#hex{ 41;re\n 42 43 }" #"ABC" (#x63 #x41 #x42 #x43))
;; No comments: (cross-check "#hex{ 41;re\n 42 43 }" #"ABC" (#x63 #x41 #x42 #x43))
(check-exn exn? (lambda () (string->preserve "#hex{414 243}"))) ;; bytes must be 2-digits entire
(cross-check "#base64{Y29yeW1i}" #"corymb" (#x66 "corymb"))
(cross-check "#base64{Y29 yeW 1i}" #"corymb" (#x66 "corymb"))
(cross-check ";; a comment\n#base64{\n;x\nY29 yeW 1i}" #"corymb" (#x66 "corymb"))
;; No comments: (cross-check ";; a comment\n#base64{\n;x\nY29 yeW 1i}" #"corymb" (#x66 "corymb"))
(cross-check "#base64{SGk=}" #"Hi" (#x62 "Hi"))
(cross-check "#base64{SGk}" #"Hi" (#x62 "Hi"))
(cross-check "#base64{ S G k }" #"Hi" (#x62 "Hi"))
@ -666,7 +663,7 @@
(cross-check "#value#base64{AQ}" #t (#x01))
(cross-check "#value#base64{AQ==}" #t (#x01))
(cross-check "#value #base64{AQ==}" #t (#x01))
(cross-check "#value ;;comment\n #base64{AQ==}" #t (#x01))
;; No comments: (cross-check "#value ;;comment\n #base64{AQ==}" #t (#x01))
(check-equal? (string->preserve "[]") '())
(check-equal? (string->preserve "{}") (hash))
@ -740,6 +737,8 @@
(check-equal? (d (expected #x26 #x61 "a" #x36)) #"a")
(check-equal? (d (expected #x27 #x61 "a" #x37)) 'a)
(cross-check "[\"a\"\"b\"]" (list "a" "b") (#xC2 #x51 #x61 #x51 #x62))
(struct date (year month day) #:prefab)
(struct thing (id) #:prefab)
(struct person thing (name date-of-birth) #:prefab)