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

Support more robust integer lexing (hex, octal, and arbitrary radix) #108

Open
3 tasks
jeaye opened this issue Oct 12, 2024 · 1 comment
Open
3 tasks

Support more robust integer lexing (hex, octal, and arbitrary radix) #108

jeaye opened this issue Oct 12, 2024 · 1 comment
Assignees

Comments

@jeaye
Copy link
Member

jeaye commented Oct 12, 2024

Clojure docs: https://www.clojure.org/guides/learn/syntax#_numeric_types

In particular, we need to support the following:

  • Octal literals (prefixed with 0)
  • Hex literals (prefixed with 0x) -- case insensitive
  • Arbitrary radix (prefixed with N and then r, where N is the radix; e.g. 2r10101 for binary, 16rbadf00d for hex)

We can use std::stol for all of this, which also takes in the radix. We should check the position output param to ensure that the full number was consumed. If not, it's invalid.

@jianlingzhong
Copy link
Contributor

i can take this one.

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

No branches or pull requests

2 participants