fix: discrepancy on leading 0's with cpp nix's behavior. #160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary & Motivation
As described in #157, Nix doesn't allow additional leading 0's on floats. Adding additional leading zeros to numbers may even break them into two tokens. (TOKEN_INT and TOKEN_FLOAT) I've also described further information in the referenced issue.
This means if we closely follow c++ Nix's behavior, with this PR, rnix tokenizes as follows. (Which represents Nix's behavior)
01.1e2
->
01.e2
->
This may fail to parse/evaluate, but we don't care at the tokenizer level.
nix-repl also shows that Nix tokenizes the same way.
@tazjin The error here may need improvement. But we can handle that further, e.g., in the tvix compiler. To give better error messages than C++ nix.
Backwards-incompatible changes
All tests on floats were run successfully. Since this only adds custom handling on leading 0's, this doesn't break any backward compatibility.
Further context
Solves #157