Skip to content
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

Add better support for rust-like number literals #908

Merged
merged 6 commits into from
Nov 22, 2023

Conversation

PizzasBear
Copy link
Contributor

Added support for underscore separators, scientific notation and suffixes (e.g. usize or f64) for numbers.
Alleviates issue #882 for number literals.

Signed-off-by: max <gmx.sht@gmail.com>
Signed-off-by: max <gmx.sht@gmail.com>
@PizzasBear PizzasBear changed the title Added better support for rust-like number literals Add better support for rust-like number literals Nov 17, 2023
@@ -252,8 +251,88 @@ fn bool_lit(i: &str) -> ParseResult<'_> {
fn num_lit(i: &str) -> ParseResult<'_> {
recognize(tuple((
opt(char('-')),
digit1,
opt(pair(char('.'), digit1)),
// digit1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a bunch of duplication here, which I'd like to avoid. I'm guessing this will require some named parsers, which would probably aid in making this code easier to understand. Also please remove the commented out version of the old code.

Signed-off-by: max <gmx.sht@gmail.com>
@PizzasBear
Copy link
Contributor Author

I've tried to reduce the duplication, and removed the commented-out code.

Signed-off-by: max <gmx.sht@gmail.com>
Copy link
Collaborator

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is close!

askama_parser/src/lib.rs Outdated Show resolved Hide resolved
askama_parser/src/lib.rs Outdated Show resolved Hide resolved
askama_parser/src/lib.rs Outdated Show resolved Hide resolved
Signed-off-by: max <gmx.sht@gmail.com>
askama_parser/src/lib.rs Outdated Show resolved Hide resolved
Signed-off-by: max <gmx.sht@gmail.com>
@djc djc merged commit 6965610 into rinja-rs:main Nov 22, 2023
20 checks passed
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.

2 participants