-
Notifications
You must be signed in to change notification settings - Fork 740
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
implement a json5 lexer #1561
Conversation
There was a problem hiding this 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!
lib/rouge/lexers/json5.rb
Outdated
rule %r/[+-]?\b(?:Infinity|NaN)\b/, Keyword::Constant | ||
rule %r/[+-]?0x\h+/i, Num::Hex | ||
|
||
rule %r/[+-]?\d*\.\d*(?:e[+-]?\d+)?/i, Num::Float |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
2c2663f
to
89624a3
Compare
Like it says on the tin! (This will close #1577.)