aboutsummaryrefslogtreecommitdiffstats
path: root/askama_parser/src/expr.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-09-28 15:22:58 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-09-28 17:28:26 +0200
commit36f4442978674a79aaebefcd4f04c7bfe6fe54c4 (patch)
tree40c53ded4ae37734cfce66c51db19df27db4d02d /askama_parser/src/expr.rs
parent57181752917c67a007c86fdbe133d2c64db7c749 (diff)
downloadaskama-36f4442978674a79aaebefcd4f04c7bfe6fe54c4.tar.gz
askama-36f4442978674a79aaebefcd4f04c7bfe6fe54c4.tar.bz2
askama-36f4442978674a79aaebefcd4f04c7bfe6fe54c4.zip
Require Expr::parse() callers to supply Level
Diffstat (limited to 'askama_parser/src/expr.rs')
-rw-r--r--askama_parser/src/expr.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/askama_parser/src/expr.rs b/askama_parser/src/expr.rs
index d676e85..3b6bced 100644
--- a/askama_parser/src/expr.rs
+++ b/askama_parser/src/expr.rs
@@ -76,17 +76,13 @@ impl<'a> Expr<'a> {
preceded(
ws(char('(')),
cut(terminated(
- separated_list0(char(','), ws(move |i| Self::nested(i, level))),
+ separated_list0(char(','), ws(move |i| Self::parse(i, level))),
char(')'),
)),
)(i)
}
- pub(super) fn parse(i: &'a str) -> IResult<&'a str, Self> {
- Self::nested(i, Level::default())
- }
-
- fn nested(i: &'a str, level: Level) -> IResult<&'a str, Self> {
+ pub(super) fn parse(i: &'a str, level: Level) -> IResult<&'a str, Self> {
let level = level.nest(i)?;
let range_right = move |i| {
pair(
@@ -172,7 +168,7 @@ impl<'a> Expr<'a> {
fn group(i: &'a str, level: Level) -> IResult<&'a str, Self> {
let level = level.nest(i)?;
- let (i, expr) = preceded(ws(char('(')), opt(|i| Self::nested(i, level)))(i)?;
+ let (i, expr) = preceded(ws(char('(')), opt(|i| Self::parse(i, level)))(i)?;
let expr = match expr {
Some(expr) => expr,
None => {
@@ -189,7 +185,7 @@ impl<'a> Expr<'a> {
let mut exprs = vec![expr];
let (i, _) = fold_many0(
- preceded(char(','), ws(|i| Self::nested(i, level))),
+ preceded(char(','), ws(|i| Self::parse(i, level))),
|| (),
|_, expr| {
exprs.push(expr);
@@ -205,7 +201,7 @@ impl<'a> Expr<'a> {
ws(char('[')),
cut(terminated(
map(
- separated_list0(char(','), ws(move |i| Self::nested(i, level))),
+ separated_list0(char(','), ws(move |i| Self::parse(i, level))),
Self::Array,
),
char(']'),
@@ -348,7 +344,7 @@ impl<'a> Suffix<'a> {
map(
preceded(
ws(char('[')),
- cut(terminated(ws(move |i| Expr::nested(i, level)), char(']'))),
+ cut(terminated(ws(move |i| Expr::parse(i, level)), char(']'))),
),
Self::Index,
)(i)