Skip to content

Commit

Permalink
refactor(parser): Update signature for 'State::tag_block_end'
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Nov 4, 2024
1 parent 51a8185 commit 3247bba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions rinja_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,8 @@ impl<'a> State<'a> {
tag(self.syntax.block_start).parse_next(i)
}

fn tag_block_end<'i>(&self, i: &'i str) -> InputParseResult<'i> {
tag(self.syntax.block_end).parse_peek(i)
fn tag_block_end<'i>(&self, i: &mut &'i str) -> ParseResult<'i> {
tag(self.syntax.block_end).parse_next(i)
}

fn tag_comment_start<'i>(&self, i: &'i str) -> InputParseResult<'i> {
Expand Down
28 changes: 14 additions & 14 deletions rinja_parser/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'a> Node<'a> {
let (i, closed) = cut_node(
None,
alt((
(unpeek(|i| s.tag_block_end(i))).value(true),
(|i: &mut _| s.tag_block_end(i)).value(true),
ws(eof).value(false),
)),
)
Expand Down Expand Up @@ -277,7 +277,7 @@ impl<'a> When<'a> {
Some("match-else"),
(
opt(unpeek(Whitespace::parse)),
unpeek(|i| s.tag_block_end(i)),
|i: &mut _| s.tag_block_end(i),
cut_node(Some("match-else"), unpeek(|i| Node::many(i, s))),
),
),
Expand Down Expand Up @@ -309,7 +309,7 @@ impl<'a> When<'a> {
Some("match-endwhen"),
(
opt(unpeek(Whitespace::parse)),
unpeek(|i| s.tag_block_end(i)),
|i: &mut _| s.tag_block_end(i),
repeat(0.., ws(unpeek(|i| Comment::parse(i, s)))).map(|()| ()),
),
),
Expand Down Expand Up @@ -337,7 +337,7 @@ impl<'a> When<'a> {
(
separated1(ws(unpeek(|i| Target::parse(i, s))), '|'),
opt(unpeek(Whitespace::parse)),
unpeek(|i| s.tag_block_end(i)),
|i: &mut _| s.tag_block_end(i),
cut_node(Some("match-when"), unpeek(|i| Node::many(i, s))),
opt(endwhen),
),
Expand Down Expand Up @@ -385,7 +385,7 @@ impl<'a> Cond<'a> {
),
)),
opt(unpeek(Whitespace::parse)),
cut_node(Some("if"), unpeek(|i| s.tag_block_end(i))),
cut_node(Some("if"), |i: &mut _| s.tag_block_end(i)),
cut_node(Some("if"), unpeek(|i| Node::many(i, s))),
)
.parse_peek(i)?;
Expand Down Expand Up @@ -514,7 +514,7 @@ impl<'a> Loop<'a> {
(
opt(unpeek(Whitespace::parse)),
delimited(
unpeek(|i| s.tag_block_end(i)),
|i: &mut _| s.tag_block_end(i),
unpeek(|i| Node::many(i, s)),
|i: &mut _| s.tag_block_start(i),
),
Expand Down Expand Up @@ -561,7 +561,7 @@ impl<'a> Loop<'a> {
ws(unpeek(|i| Expr::parse(i, s.level.get()))),
opt(if_cond),
opt(unpeek(Whitespace::parse)),
unpeek(|i| s.tag_block_end(i)),
|i: &mut _| s.tag_block_end(i),
unpeek(body_and_end),
),
),
Expand Down Expand Up @@ -620,7 +620,7 @@ impl<'a> Macro<'a> {
ws(identifier),
opt(ws(unpeek(parameters))),
opt(unpeek(Whitespace::parse)),
unpeek(|i| s.tag_block_end(i)),
|i: &mut _| s.tag_block_end(i),
),
),
);
Expand Down Expand Up @@ -701,7 +701,7 @@ impl<'a> FilterBlock<'a> {
.map(|v: Vec<_>| v),
ws(unpeek(|i| Ok((i, ())))),
opt(unpeek(Whitespace::parse)),
unpeek(|i| s.tag_block_end(i)),
|i: &mut _| s.tag_block_end(i),
),
),
);
Expand Down Expand Up @@ -860,7 +860,7 @@ impl<'a> Match<'a> {
(
ws(unpeek(|i| Expr::parse(i, s.level.get()))),
opt(unpeek(Whitespace::parse)),
unpeek(|i| s.tag_block_end(i)),
|i: &mut _| s.tag_block_end(i),
cut_node(
Some("match"),
(
Expand Down Expand Up @@ -935,7 +935,7 @@ impl<'a> BlockDef<'a> {
(
ws(identifier),
opt(unpeek(Whitespace::parse)),
unpeek(|i| s.tag_block_end(i)),
|i: &mut _| s.tag_block_end(i),
),
),
);
Expand Down Expand Up @@ -1064,7 +1064,7 @@ impl<'a> Raw<'a> {
opt(unpeek(Whitespace::parse)),
ws(keyword("endraw")), // sic: ignore `{% end %}` in raw blocks
opt(unpeek(Whitespace::parse)),
peek(unpeek(|i| s.tag_block_end(i))),
peek(|i: &mut _| s.tag_block_end(i)),
);

let mut p = (
Expand All @@ -1074,7 +1074,7 @@ impl<'a> Raw<'a> {
Some("raw"),
(
opt(unpeek(Whitespace::parse)),
unpeek(|i| s.tag_block_end(i)),
|i: &mut _| s.tag_block_end(i),
skip_till(Splitter1::new(s.syntax.block_start), endraw).with_recognized(),
),
),
Expand Down Expand Up @@ -1145,7 +1145,7 @@ impl<'a> If<'a> {
Some("if"),
(
opt(unpeek(Whitespace::parse)),
unpeek(|i| s.tag_block_end(i)),
|i: &mut _| s.tag_block_end(i),
cut_node(
Some("if"),
(
Expand Down

0 comments on commit 3247bba

Please sign in to comment.