add parsing of nan,Inf,+nnn, with variables to turn on/off; add float validation#49
add parsing of nan,Inf,+nnn, with variables to turn on/off; add float validation#49jetmonk wants to merge 2 commits intophmarek:masterfrom
Conversation
* \*allow-nan\* - allows parsing of Nan,Inf,Infinity into 'nan 'plus-infinity 'minus-infinity * \*yason-float-parser\* - allows separate float parser for floats * \*yason-float-type\* - now 'double-float - sets output type of floats * \*allow-loose-floats\* - allow floats (and Inf,NaN) with leading +, and allow d,D to be symbol for exponent in floats (not in JSON standard) * add float validation function to avoid interning of (eg) "0dd+d" by lisp reader when reading a float
|
I thought of doing this, but I have my own older parse-float (with same name, unfortunately). Also, I thought that the built-in Lisp reader has the advantage of being rigorously read-write consistent, unlike 3rd party libraries, which might make it a better default. So I put a sanity check in front of the Lisp float parser, and made the use of any other parse-float optional using eg |
|
|
||
|
|
||
| #:*allow-nan* | ||
| #:*yason-float-parser* |
There was a problem hiding this comment.
Please drop the yason- prefix - the package should make clear where the symbols are from.
| #:true | ||
| #:false | ||
| #:null | ||
| #:nan |
There was a problem hiding this comment.
About :NAN and ±∞ I'd like to see what CSR is doing about them - we'll want to be compatible. (See http://www.sbcl.org/sbcl20/ for the one-line note.)
|
|
||
|
|
||
|
|
||
| ;; verify that the buffer contains a float, and is not a symbol like |
There was a problem hiding this comment.
I'm not sure I like this code-duplication - first checking for validity, and then parsing, with a lot of code overlap.
That's why I asked about using PARSE-FLOAT - use an IGNORE-ERRORS around it to check or so, I hope this could be done in a single pass.
Let's see what CSR comes up with.
*allow-nan* - allows parsing of Nan,Inf,Infinity into 'nan 'plus-infinity 'minus-infinity
*yason-float-parser* - allows separate float parser for floats
*yason-float-type* - now 'double-float - sets output type of floats
*allow-loose-floats* - allow floats (and Inf,NaN) with leading +, and allow d,D to be symbol for exponent in floats (not in JSON standard)
add float validation function to avoid interning of (eg) "0dd+d" by lisp reader when reading a float