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 lexing reals with scientific notation #96

Open
jeaye opened this issue Oct 4, 2024 · 1 comment
Open

Support lexing reals with scientific notation #96

jeaye opened this issue Oct 4, 2024 · 1 comment

Comments

@jeaye
Copy link
Member

jeaye commented Oct 4, 2024

Clojure inherits Java's support for scientific notation: https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10.2
C++'s floating point docs: https://en.cppreference.com/w/cpp/language/floating_literal

For jank, we want to expand the lexer to support this for reals. Fortunately, we just need to be able to figure out when the token ends. Then we can use std::stold in order to get the actual value from it: https://en.cppreference.com/w/cpp/string/basic_string/stof

I'm sure there are many possible ways to misrepresent these numbers, so the negative test cases for this should be aplenty.

The lexing of numbers starts here: https:/jank-lang/jank/blob/main/compiler%2Bruntime/src/cpp/jank/read/lex.cpp#L370
The tests for reals start here: https:/jank-lang/jank/blob/main/compiler%2Bruntime/test/cpp/jank/read/lex.cpp#L448

@Samy-33
Copy link
Contributor

Samy-33 commented Oct 12, 2024

@jeaye, working on this

@jeaye jeaye assigned jeaye and Samy-33 and unassigned jeaye Oct 12, 2024
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