-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
Support input of hex, octal, and binary numbers #339
Conversation
504f6d3
to
b3d6a2d
Compare
src/Insect/Parser.purs
Outdated
numberPrefix /\ digit' /\ expSymbol ← | ||
option ("" /\ digit /\ "e") $ char '0' | ||
*> ((char 'x' <|> char 'X') $> ("0x" /\ hexDigit /\ "p") | ||
<|> (char 'o' <|> char 'O') $> ("0o" /\ octDigit /\ "p") | ||
<|> (char 'b' <|> char 'B') $> ("0b" /\ (oneOf ['0', '1'] <?> "binary digit") /\ "p")) |
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.
kill me, what have I done
b3d6a2d
to
2ce4688
Compare
I think it's perfectly fine as long as we add enough tests to make sure that everything is alright. Having a good test coverage also allows us to refactor with confidence later, if needed. |
Good point, I will add comprehensive tests. |
2ce4688
to
9b83aa0
Compare
1ddd7d6
to
8f73b02
Compare
shouldFail "0xG" | ||
shouldFail "0oG" | ||
shouldFail "0oA" | ||
shouldFail "0b2" | ||
shouldFail "0be" | ||
shouldFail "0x1p+" | ||
shouldFail "0x1p-" | ||
shouldFail "0x5.." |
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.
👍 👍
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.
Apart from the minor docu thing, this looks great. Thank you
8f73b02
to
6753533
Compare
Fixes #245.
I'm really, really ashamed of the terrible way I implemented this, but I honestly could not think of a way to do it that wouldn't be nearly as bad. Suggestions for alternate implementations or ways to improve the existing one are very welcome.
TODO: