Ticket #317 (closed defect: fixed)

Opened 12 years ago

Last modified 11 years ago

Number parsing bugs

Reported by: anonymous Owned by: dherman
Priority: blocker Milestone:
Component: dherman/json.plt Keywords:
Cc: jpc Version: (3 0)
Racket Version:


Current number parser is unable to parse negative numbers as well as numbers with decimal points and exponents. I have a small patch to fix this.

Change History

Changed 12 years ago by jpc

  • cc jpc added

Unfortunately attachments do not work so I am pasting the patch here:

--- main.ss.old 2010-12-27 16:31:03.000000000 +0100
+++ main.ss 2010-12-27 16:32:48.000000000 +0100
@@ -163,17 +163,16 @@


(define (read/exponent port)

- (expect (read-char port) #\e #\E)

(let ([sign (case (peek-char port)

[(#\- #\+) (list (read-char port))]
[else '()])])

(append sign (read/digits port))))

(define (read/number port)

- (let* ([sign (if (eq? (peek-char port) #\-) '(#\-) '())]
+ (let* ([sign (if (eq? (peek-char port) #\-) (list (read-char port)) '())]

[digits (read/digits port)]

- [frac (if (eq? (peek-char port) #\.) (read/digits port) '())]
- [exp (if (memq (peek-char port) '(#\e #\E)) (read/exponent port) '())])
+ [frac (if (eq? (peek-char port) #\.) (list* (read-char port) (read/digits port)) '())]
+ [exp (if (memq (peek-char port) '(#\e #\E)) (list* (read-char port) (read/exponent port)) '())])



(append sign digits frac exp)))))

Changed 11 years ago by dherman

  • status changed from new to closed
  • resolution set to fixed

Fixed and updated.


Note: See TracTickets for help on using tickets.