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.
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/stofI'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://github.com/jank-lang/jank/blob/main/compiler%2Bruntime/src/cpp/jank/read/lex.cpp#L370 The tests for reals start here: https://github.com/jank-lang/jank/blob/main/compiler%2Bruntime/test/cpp/jank/read/lex.cpp#L448