Skip to content
This repository has been archived by the owner on Sep 19, 2018. It is now read-only.

Allow leading zero with exponents; e.g., "0e1". #201

Merged

Conversation

jgallagher
Copy link
Contributor

Fixes one of the two issues brought up in #198.

Fixes one of the two issues brought up in #198.
("-0", 0),
("0e1", 0),
("-0e20", 0),
("0.1e1", 1),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check with negative exponent and zero exponent, as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also toss in one with uppercase E to check we handle that variant spelling.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And maybe more fun with leading zeroes, too, like 0001E0001 for 10.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 on neg/zero exponent and uppercase E. Leading zeros are not allowed in JSON, and we already have a unit test to confirm they're rejected.

Copy link
Member

@jeremy-w jeremy-w Aug 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a leading zero is admitted for the exponent, though. The number production uses int restricted to be zero or non-zero and then whatever digits, but exp is just "at least one digit" in its numeric part, so leading zeroes are legit there.

      number = [ minus ] int [ frac ] [ exp ]

      decimal-point = %x2E       ; .

      digit1-9 = %x31-39         ; 1-9

      e = %x65 / %x45            ; e E

      exp = e [ minus / plus ] 1*DIGIT

      frac = decimal-point 1*DIGIT

      int = zero / ( digit1-9 *DIGIT )

      minus = %x2D               ; -

      plus = %x2B                ; +

      zero = %x30                ; 0

https://tools.ietf.org/html/rfc7159 section 6 (page 6)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 711f3a7

@jeremy-w
Copy link
Member

jeremy-w commented Sep 1, 2016

👍 LGTM

@jgallagher jgallagher merged commit c630c95 into master Sep 1, 2016
@jgallagher jgallagher deleted the jgallagher/fix-parsing-leading-zero-with-exponent branch September 1, 2016 17:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants