Updated to the latest nom
This commit is contained in:
parent
28b5cf1d34
commit
d30749f709
@ -2,3 +2,6 @@ extern crate nom;
|
||||
|
||||
mod parser;
|
||||
mod renderer;
|
||||
|
||||
pub use renderer::compile_template;
|
||||
pub use renderer::DustRenderer;
|
||||
|
@ -17,8 +17,7 @@ use nom::combinator::value;
|
||||
use nom::combinator::verify;
|
||||
use nom::multi::many0;
|
||||
use nom::multi::many1;
|
||||
use nom::multi::separated_list;
|
||||
use nom::multi::separated_nonempty_list;
|
||||
use nom::multi::separated_list1;
|
||||
use nom::sequence::delimited;
|
||||
use nom::sequence::preceded;
|
||||
use nom::sequence::separated_pair;
|
||||
@ -198,9 +197,7 @@ fn key(i: &str) -> IResult<&str, &str> {
|
||||
|
||||
/// A series of keys separated by '.' to reference a variable in the context
|
||||
fn path(i: &str) -> IResult<&str, Path> {
|
||||
map(separated_nonempty_list(tag("."), key), |body| Path {
|
||||
keys: body,
|
||||
})(i)
|
||||
map(separated_list1(tag("."), key), |body| Path { keys: body })(i)
|
||||
}
|
||||
|
||||
/// Either a literal or a path to a value
|
||||
@ -234,7 +231,7 @@ fn reference(i: &str) -> IResult<&str, Reference> {
|
||||
fn conditional<'a, F>(
|
||||
open_matcher: &'static str,
|
||||
constructor: F,
|
||||
) -> impl Fn(&'a str) -> IResult<&'a str, DustTag<'a>>
|
||||
) -> impl FnMut(&'a str) -> IResult<&'a str, DustTag<'a>>
|
||||
where
|
||||
F: Copy + Fn(Container<'a>) -> DustTag<'a>,
|
||||
{
|
||||
@ -297,7 +294,7 @@ where
|
||||
fn named_block<'a, F>(
|
||||
open_matcher: &'static str,
|
||||
constructor: F,
|
||||
) -> impl Fn(&'a str) -> IResult<&'a str, DustTag<'a>>
|
||||
) -> impl FnMut(&'a str) -> IResult<&'a str, DustTag<'a>>
|
||||
where
|
||||
F: Copy + Fn(NamedBlock<'a>) -> DustTag<'a>,
|
||||
{
|
||||
@ -358,7 +355,7 @@ fn parameterized_block<'a, F>(
|
||||
open_matcher: &'static str,
|
||||
tag_name: &'static str,
|
||||
constructor: F,
|
||||
) -> impl Fn(&'a str) -> IResult<&'a str, DustTag<'a>>
|
||||
) -> impl FnMut(&'a str) -> IResult<&'a str, DustTag<'a>>
|
||||
where
|
||||
F: Copy + Fn(ParameterizedBlock<'a>) -> DustTag<'a>,
|
||||
{
|
||||
@ -380,7 +377,7 @@ where
|
||||
let (i, (name, params, inner, maybe_else, _closing_name)) = tuple((
|
||||
preceded(tag(open_matcher), tag(tag_name)),
|
||||
terminated(
|
||||
opt(preceded(space1, separated_list(space1, key_value_pair))),
|
||||
opt(preceded(space1, separated_list1(space1, key_value_pair))),
|
||||
tag("}"),
|
||||
),
|
||||
opt(body),
|
||||
@ -413,7 +410,7 @@ where
|
||||
tag(open_matcher),
|
||||
tuple((
|
||||
tag(tag_name),
|
||||
opt(preceded(space1, separated_list(space1, key_value_pair))),
|
||||
opt(preceded(space1, separated_list1(space1, key_value_pair))),
|
||||
)),
|
||||
tag("/}"),
|
||||
)(i)?;
|
||||
@ -442,7 +439,7 @@ where
|
||||
tag(open_matcher),
|
||||
tuple((
|
||||
alt((map(key, String::from), quoted_string)),
|
||||
opt(preceded(space1, separated_list(space1, key_value_pair))),
|
||||
opt(preceded(space1, separated_list1(space1, key_value_pair))),
|
||||
)),
|
||||
tag("/}"),
|
||||
)(i)?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user