Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing exponent notation in json-parser #36

Closed
nandanvasudevan opened this issue Jan 17, 2022 · 3 comments
Closed

Parsing exponent notation in json-parser #36

nandanvasudevan opened this issue Jan 17, 2022 · 3 comments

Comments

@nandanvasudevan
Copy link

nandanvasudevan commented Jan 17, 2022

I just saw that the to_js_number() does not work when the exponent does not have a sign (like 1.0e8).
A quick look into the JSON schema tells me that it is allowed.

image

Was this missed or is support for these not required?

Here is a simple fix anyway. I am happy to provide a pull request if this is necessary.
Just confused right now.

https://godbolt.org/z/7bo3d41K6

@nandanvasudevan nandanvasudevan changed the title Prasing exponent notation in json-parser Parsing exponent notation in json-parser Jan 17, 2022
@peter-winter
Copy link
Owner

This is my mistake. First of all a fix to the regex is needed. The way you fixed it in to_js_number is way too complicated.
I would do it like this:

exp_minus = *it == '-';
if (*it == '-' || *it == '+') ++it;

@nandanvasudevan
Copy link
Author

nandanvasudevan commented Jan 17, 2022

I agree.
Please go ahead!

Tested, just in case... Works as expected!
https://godbolt.org/z/YnYhK7jMo

@peter-winter
Copy link
Owner

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants