Skip to content

Implement arbitrary suffixes (for all literals) #10

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

Merged
merged 11 commits into from
Mar 5, 2023

Conversation

LukasKalbertodt
Copy link
Owner

Closes #2

Quite a few breaking changes due to this change. This should fix the last known difference between litrs and the Rust compiler.

Just two methods and two trait impls for `IntegerType` and `FloatType`
This is quite a big change. Its main motivation is to allow for
arbitrary suffixes, as allowed by the grammar (e.g. `23px`). This
required the following changes:

- Replace method `type_suffix` by `suffix(&self) -> &str`. Users are
  expected to use `{Integer|Float}Type::from_suffix` to get the type.
- Change parsing to accept any suffix.
- Add function to check a suffix for validity.
- Change `Literal::parse` to only attempt to parse a float literal if it
  contains a fractional or exponent part. This is a breaking behavior
  change as previously `0f32` was parsed as float literal.
- `FloatLit::parse` now rejects integer literals like `23` or `23f32`.
- Adjusting all tests
This gets rid of a bit of duplication and might improve compile times
(for the downstream crate) as all string parsing functions are now
compiled once (without generics).
This improves the rendered docs.
@LukasKalbertodt LukasKalbertodt merged commit fcaf249 into main Mar 5, 2023
@LukasKalbertodt LukasKalbertodt deleted the arbitrary-suffixes branch March 5, 2023 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support non-number suffixes
1 participant