Ticket #674: push-exactness-into-hook.diff

File push-exactness-into-hook.diff, 3.9 KB (added by felix winkelmann, 13 years ago)
  • library.scm

    diff --git a/library.scm b/library.scm
    index 8ceb7de..defadb3 100644
    a b EOF 
    10701070                  (##sys#lcm head n2)
    10711071                  (##sys#slot next 1)) #f) ) ) ) ) ) )
    10721072
    1073 (define (##sys#string->number str #!optional (radix 10))
    1074   (##core#inline_allocate ("C_a_i_string_to_number" 4) str radix))
     1073(define (##sys#string->number str #!optional (radix 10) exactness)
     1074  (let ((num (##core#inline_allocate ("C_a_i_string_to_number" 4) str radix)))
     1075    (case exactness
     1076      ((i) (##core#inline_allocate ("C_a_i_exact_to_inexact" 4) num))
     1077      ((e) (##core#inline "C_i_inexact_to_exact" num))
     1078      (else num))))
    10751079
    10761080(define string->number ##sys#string->number)
    10771081(define ##sys#number->string (##core#primitive "C_number_to_string"))
    EOF 
    25262530                  (##sys#list->vector lst)
    25272531                  (##sys#read-error port "invalid vector syntax" lst) ) ) )
    25282532         
    2529           (define (r-number radix)
     2533          (define (r-number radix exactness)
    25302534            (set! rat-flag #f)
    25312535            (let ([tok (r-token)])
    25322536              (if (string=? tok ".")
    25332537                  (##sys#read-error port "invalid use of `.'")
    2534                   (let ([val (##sys#string->number tok (or radix 10))] )
     2538                  (let ([val (##sys#string->number tok (or radix 10) exactness)] )
    25352539                    (cond [val
     2540                           ;;XXX move this into ##sys#string->number ?
    25362541                           (when (and (##sys#inexact? val) rat-flag)
    25372542                             (##sys#read-warning
    25382543                              port
    EOF 
    25472552                   (let ([c2 (##sys#read-char-0 port)])
    25482553                     (cond [(eof-object? c2)
    25492554                            (##sys#read-error port "unexpected end of numeric literal")]
    2550                            [(char=? c2 #\i) (##sys#exact->inexact (r-number radix))]
    2551                            [(char=? c2 #\e) (##sys#inexact->exact (r-number radix))]
     2555                           [(char=? c2 #\i) (r-number radix 'i)]
     2556                           [(char=? c2 #\e) (r-number radix 'e)]
    25522557                           [else
    25532558                            (##sys#read-error
    25542559                             port
    25552560                             "illegal number syntax - invalid exactness prefix" c2)] ) ) ]
    2556                   [else (r-number radix)] ) )
     2561                  [else (r-number radix #f)] ) )
    25572562         
    2558           (define (r-number-with-radix)
     2563          (define (r-number-with-radix exactness)
    25592564            (cond [(char=? #\# (##sys#peek-char-0 port))
    25602565                   (##sys#read-char-0 port)
    25612566                   (let ([c2 (##sys#read-char-0 port)])
    25622567                     (cond [(eof-object? c2) (##sys#read-error port "unexpected end of numeric literal")]
    2563                            [(char=? c2 #\x) (r-number 16)]
    2564                            [(char=? c2 #\d) (r-number 10)]
    2565                            [(char=? c2 #\o) (r-number 8)]
    2566                            [(char=? c2 #\b) (r-number 2)]
     2568                           [(char=? c2 #\x) (r-number 16 exactness)]
     2569                           [(char=? c2 #\d) (r-number 10 exactness)]
     2570                           [(char=? c2 #\o) (r-number 8 exactness)]
     2571                           [(char=? c2 #\b) (r-number 2 exactness)]
    25672572                           [else (##sys#read-error port "illegal number syntax - invalid radix" c2)] ) ) ]
    2568                   [else (r-number 10)] ) )
     2573                  [else (r-number 10 exactness)] ) )
    25692574       
    25702575          (define (r-token)
    25712576            (let loop ((c (##sys#peek-char-0 port)) (lst '()))
    EOF 
    27832788                                 ((#\d) (##sys#read-char-0 port) (r-number-with-exactness 10))
    27842789                                 ((#\o) (##sys#read-char-0 port) (r-number-with-exactness 8))
    27852790                                 ((#\b) (##sys#read-char-0 port) (r-number-with-exactness 2))
    2786                                  ((#\i) (##sys#read-char-0 port) (##sys#exact->inexact (r-number-with-radix)))
    2787                                  ((#\e) (##sys#read-char-0 port) (##sys#inexact->exact (r-number-with-radix)))
     2791                                 ((#\i) (##sys#read-char-0 port) (r-number-with-radix 'i))
     2792                                 ((#\e) (##sys#read-char-0 port) (r-number-with-radix 'e))
    27882793                                 ((#\c)
    27892794                                  (##sys#read-char-0 port)
    27902795                                  (let ([c (##sys#read-char-0 port)])
    EOF 
    28522857                  ((#\() (r-list #\( #\)))
    28532858                  ((#\)) (##sys#read-char-0 port) (container c))
    28542859                  ((#\") (##sys#read-char-0 port) (r-string #\"))
    2855                   ((#\.) (r-number #f))
    2856                   ((#\- #\+) (r-number #f))
     2860                  ((#\.) (r-number #f #f))
     2861                  ((#\- #\+) (r-number #f #f))
    28572862                  (else
    28582863                   (cond [(eof-object? c) c]
    2859                          [(char-numeric? c) (r-number #f)]
     2864                         [(char-numeric? c) (r-number #f #f)]
    28602865                         ((memq c reserved-characters)
    28612866                          (reserved-character c))
    28622867                         (else