Feat: Added missing numeric literal classes, python string can now support all numerical types #277
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.
Pull Request description
At the start, I wanted to fix a problem with the python string transpiler not supporting most Int, Uint, LiteralInt and LiteralUint node types.
This pull request fix this problem but also reorganize the heritage tree a little bit for numeric literals.
There are 4 types of literal numeric type in astx: int, uint, float and complex. Complex was the only one with its own parent class. The 3 other types had a lot of duplicated code in the implementation of all their variations. I added the parent classes LiterarlInt, LiteralUint, and LiteralFloat.
This issue does not fix any announced issue. But it could touch a little bit of issue #254
How to test these changes
Tests for Literal numeric types got updated to also test the three new classes.
Many tests are also added for the python string transpiler to make sure all numeric node types are being converted correctly.
Pull Request checklists
Note:
proposed in this PR, in both image and ASCII formats. For more
information, check this Google Colab notebook:
https://colab.research.google.com/drive/1xXwHmOMkJKFSmhRvn4WYfSAsdDzMnawf?usp=sharing
This PR is a:
About this PR:
Author's checklist:
complexity.
Additional information
Here is a literal diagram to show the new class in the heritage tree, it only show the LiteralInt class but it is the same idea for LiteralUint and LiteralFloat.
Reviewer's Checklist
main
branch