/[cl-l10n]/cl-l10n/parse-number.lisp
ViewVC logotype

Diff of /cl-l10n/parse-number.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by sross, Thu Dec 30 11:56:38 2004 UTC revision 1.4 by sross, Thu Mar 31 13:53:42 2005 UTC
# Line 32  Line 32 
32    
33  (in-package #:cl-l10n)  (in-package #:cl-l10n)
34    
35  (define-condition invalid-number ()  (define-condition parser-error (error)
36    ((value :reader value    ((value :reader value
37            :initarg :value            :initarg :value
38            :initform nil)            :initform nil)
# Line 40  Line 40 
40             :initarg :reason             :initarg :reason
41             :initform "Not specified"))             :initform "Not specified"))
42    (:report (lambda (c s)    (:report (lambda (c s)
43               (cl:format s "Invalid number: ~S [Reason: ~A]"               (cl:format s "Unable to parse: ~S [Reason: ~A]"
44                     (value c) (reason c)))))                     (value c) (reason c)))))
45    
46  (declaim (inline parse-integer-and-places))  (declaim (inline parse-integer-and-places))
# Line 106  Line 106 
106  (defun %parse-number (string &key (start 0) (end nil) (radix 10))  (defun %parse-number (string &key (start 0) (end nil) (radix 10))
107    "Given a string, and start, end, and radix parameters, produce a number according to the syntax definitions in the Common Lisp Hyperspec."    "Given a string, and start, end, and radix parameters, produce a number according to the syntax definitions in the Common Lisp Hyperspec."
108    (flet ((invalid-number (reason)    (flet ((invalid-number (reason)
109             (error 'invalid-number             (error 'parser-error
110                    :value (subseq string start end)                    :value (subseq string start end)
111                    :reason reason)))                    :reason reason)))
112      (let ((end (or end (length string))))      (let ((end (or end (length string))))
# Line 179  Line 179 
179                                         :end end                                         :end end
180                                         :key #'char-downcase)))                                         :key #'char-downcase)))
181                    (unless r-pos                    (unless r-pos
182                      (error 'invalid-number                      (error 'parser-error
183                             :value (subseq string start end)                             :value (subseq string start end)
184                             :reason "Missing R in #radixR"))                             :reason "Missing R in #radixR"))
185                    (parse-real-number string                    (parse-real-number string
# Line 198  Line 198 
198    (let ((end (or end (length string)))    (let ((end (or end (length string)))
199          (first-char (char string start)))          (first-char (char string start)))
200      (flet ((invalid-number (reason)      (flet ((invalid-number (reason)
201               (error 'invalid-number               (error 'parser-error
202                      :value (subseq string start end)                      :value (subseq string start end)
203                      :reason reason))                      :reason reason))
204             (base-for-exponent-marker (char)             (base-for-exponent-marker (char)

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.5