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

implement a json5 lexer #1561

Merged
merged 5 commits into from
Nov 11, 2024
Merged

implement a json5 lexer #1561

merged 5 commits into from
Nov 11, 2024

Conversation

jneen
Copy link
Member

@jneen jneen commented Jul 18, 2020

Like it says on the tin! (This will close #1577.)

@pyrmont pyrmont self-assigned this Jul 23, 2020
@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Jul 23, 2020
@hugopeixoto hugopeixoto mentioned this pull request Sep 7, 2020
Copy link
Contributor

@pyrmont pyrmont left a comment

Choose a reason for hiding this comment

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

@jneen I made a change to what I think are duplicative rules. Let me know what you think!

rule %r/[+-]?\b(?:Infinity|NaN)\b/, Keyword::Constant
rule %r/[+-]?0x\h+/i, Num::Hex

rule %r/[+-]?\d*\.\d*(?:e[+-]?\d+)?/i, Num::Float
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this rule matches everything that would have been matched by the below two rules

rule %r/[+-]?[.]\d+/, Num::Float
rule %r/[+-]?\d+[.]/, Num::Float

so I took them out.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jneen Are you happy with this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

As long as the visual spec looks good! I would have put any edge cases in there.

Copy link
Member Author

Choose a reason for hiding this comment

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

I should note that this matches just plain ., which I don't think is valid syntax

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. Maybe we should put the two rules back and copy the exponent portion into them?

Copy link
Member Author

@jneen jneen Oct 13, 2020

Choose a reason for hiding this comment

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

you could avoid this case with (?:\d+[.]\d*|[.]\d+) which would be plenty performant i think.

Copy link

Choose a reason for hiding this comment

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

What happened to this? almost 5 years has progressed, I'm not really a Ruby dev but it would be nice to see this moving forward rather than stagnating.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@robvdl Thank you for your patience. This has slipped my radar. I can take over and have look at it.

Copy link

Choose a reason for hiding this comment

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

I just came across it for the first time today :) it's fine.

I ran into it because Jetbrains IDE's render json5 while Gitlab didn't.

@pyrmont pyrmont added author-action The PR has been reviewed but action by the author is needed and removed needs-review The PR needs to be reviewed labels Sep 8, 2020
@pyrmont pyrmont removed their assignment Dec 9, 2020
@tancnle tancnle self-assigned this Oct 30, 2024
@tancnle tancnle added this pull request to the merge queue Nov 11, 2024
Merged via the queue into master with commit d0f6168 Nov 11, 2024
8 checks passed
@tancnle tancnle deleted the feature.json5 branch November 11, 2024 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author-action The PR has been reviewed but action by the author is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON5 support
4 participants