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

Upgrade to nom 7 #530

Merged
merged 1 commit into from
Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion askama_shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ yaml = ["serde", "serde_yaml"]
[dependencies]
askama_escape = { version = "0.10", path = "../askama_escape" }
humansize = { version = "1.1.0", optional = true }
nom = { version = "6.2.1", features = ["std"], default-features = false } # Gets us a newer version of bitvec https://github.com/Geal/nom/issues/1311#issuecomment-880902973
nom = "7"
num-traits = { version = "0.2.6", optional = true }
proc-macro2 = "1"
quote = "1"
Expand Down
14 changes: 9 additions & 5 deletions askama_shared/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use nom::combinator::{complete, cut, map, opt, recognize, value};
use nom::error::{Error, ParseError};
use nom::multi::{fold_many0, many0, many1, separated_list0, separated_list1};
use nom::sequence::{delimited, pair, preceded, terminated, tuple};
use nom::{self, error_position, Compare, IResult, InputTake};
use nom::{self, error_position, Compare, IResult, InputLength, InputTake};
use std::str;

use crate::{CompileError, Syntax};
Expand Down Expand Up @@ -126,7 +126,7 @@ pub struct CondTest<'a> {
fn ws<F, I, O, E>(mut inner: F) -> impl FnMut(I) -> IResult<I, O, E>
where
F: FnMut(I) -> IResult<I, O, E>,
I: InputTake + Clone + PartialEq + for<'a> Compare<&'a [u8; 1]>,
I: InputLength + InputTake + Clone + PartialEq + for<'a> Compare<&'a [u8; 1]>,
E: ParseError<I>,
{
move |i: I| {
Expand Down Expand Up @@ -388,9 +388,13 @@ fn target(i: &[u8]) -> IResult<&[u8], Target<'_>> {

let mut targets = vec![first_target];
let (i, _) = cut(tuple((
fold_many0(preceded(ws(tag(",")), target), (), |_, target| {
targets.push(target);
}),
fold_many0(
preceded(ws(tag(",")), target),
|| (),
|_, target| {
targets.push(target);
},
),
opt(ws(tag(","))),
ws(cut(tag(")"))),
)))(i)?;
Expand Down