Parsing numbers
Pre-releaseAgain what seems like a minor addition represents months of work and that one long weekend. I've learned that parsing number is a really annoying and complex task.
It became a bit easier when I realized I can use the strength of Parsec to parse the contents of the literals (or just values) passed to tonumber
. That didn't really help with the conversion process. This became much more reasonable once I realized that while Lua allows numbers in arbitrary bases, it only does that for integers; floating-point numbers are restricted to base 10.
This means I can delegate the base-10 parsing to existing, good implementations, and just do the base-n integers myself. I still don't particularly like this implementation, but since it lives in its own, isolated module, I can improve it whenever I feel the need for it.
One additional caveat is that I found a bug in the actual parser; it doesn't allow numbers starting or ending with a dot, which got an issue with an apt number #69. This will be solved separately.