-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
Conversation
Signed-off-by: max <gmx.sht@gmail.com>
Signed-off-by: max <gmx.sht@gmail.com>
askama_parser/src/lib.rs
Outdated
@@ -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, |
There was a problem hiding this comment.
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>
I've tried to reduce the duplication, and removed the commented-out code. |
Signed-off-by: max <gmx.sht@gmail.com>
There was a problem hiding this 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!
Signed-off-by: max <gmx.sht@gmail.com>
Signed-off-by: max <gmx.sht@gmail.com>
Added support for underscore separators, scientific notation and suffixes (e.g.
usize
orf64
) for numbers.Alleviates issue #882 for number literals.