Skip to content

Commit

Permalink
refactor(parser): Update signature for 'Expr::arguments'
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Nov 25, 2024
1 parent 29ba02c commit cc6dd89
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions rinja_parser/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use winnow::stream::Stream as _;
use winnow::{Parser, unpeek};

use crate::{
CharLit, ErrorContext, InputParseResult, Level, Num, ParseErr, ParseResult, PathOrIdentifier,
Span, StrLit, WithSpan, char_lit, filter, identifier, keyword, num_lit, path_or_identifier,
skip_ws0, skip_ws1, str_lit, ws,
CharLit, ErrorContext, Level, Num, ParseErr, ParseResult, PathOrIdentifier, Span, StrLit,
WithSpan, char_lit, filter, identifier, keyword, num_lit, path_or_identifier, skip_ws0,
skip_ws1, str_lit, ws,
};

macro_rules! expr_prec_layer {
Expand Down Expand Up @@ -132,13 +132,13 @@ pub enum Expr<'a> {

impl<'a> Expr<'a> {
pub(super) fn arguments(
i: &'a str,
i: &mut &'a str,
level: Level,
is_template_macro: bool,
) -> InputParseResult<'a, Vec<WithSpan<'a, Self>>> {
) -> ParseResult<'a, Vec<WithSpan<'a, Self>>> {
let level = level.nest(i)?;
let mut named_arguments = HashSet::new();
let start = i;
let start = *i;

preceded(
ws('('),
Expand Down Expand Up @@ -177,7 +177,7 @@ impl<'a> Expr<'a> {
(opt(ws(',')), ')'),
)),
)
.parse_peek(i)
.parse_next(i)
}

fn named_argument(
Expand Down Expand Up @@ -673,7 +673,7 @@ impl<'a> Suffix<'a> {

fn call(i: &mut &'a str, level: Level) -> ParseResult<'a, Self> {
let level = level.nest(i)?;
unpeek(move |i| Expr::arguments(i, level, false))
(move |i: &mut _| Expr::arguments(i, level, false))
.map(Self::Call)
.parse_next(i)
}
Expand Down
2 changes: 1 addition & 1 deletion rinja_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ fn filter<'a>(
*level = level.nest(start)?;
cut_err((
ws(identifier),
opt(unpeek(|i| Expr::arguments(i, *level, false))),
opt(|i: &mut _| Expr::arguments(i, *level, false)),
))
.parse_next(i)
}
Expand Down
6 changes: 3 additions & 3 deletions rinja_parser/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ impl<'a> FilterBlock<'a> {
Some("filter"),
(
ws(identifier),
opt(unpeek(|i| Expr::arguments(i, s.level.get(), false))),
opt(|i: &mut _| Expr::arguments(i, s.level.get(), false)),
repeat(0.., |i: &mut _| {
let start = *i;
filter(i, &mut level).map(|(name, params)| (name, params, start))
Expand Down Expand Up @@ -905,9 +905,9 @@ impl<'a> Call<'a> {
(
opt((ws(identifier), ws("::"))),
ws(identifier),
opt(ws(unpeek(|nested| {
opt(ws(|nested: &mut _| {
Expr::arguments(nested, s.level.get(), true)
}))),
})),
opt(unpeek(Whitespace::parse)),
),
),
Expand Down

0 comments on commit cc6dd89

Please sign in to comment.