Skip to content

Commit

Permalink
gotta parse for the right grouping symbols!
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokathor committed Nov 24, 2024
1 parent 823e69f commit dade1ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/ast/parsing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,19 @@ where
}
}

/// Lets you `select_ref!` the content out of some `Brackets`
pub fn nested_bracket_content_p<'src, I, M>(
make_input: M,
) -> impl Parser<'src, I, I, ErrRichTokenTree<'src>> + Clone
where
I: BorrowInput<'src, Token = TokenTree, Span = FileSpan> + ValueInput<'src>,
M: Fn(&'src [FileSpanned<TokenTree>], FileSpan) -> I + Copy + 'src,
{
select_ref! {
Brackets(b) = ex => make_input(b, ex.span()),
}
}

/// Lets you `select_ref!` the content out of some `Parens`
pub fn nested_parens_content_p<'src, I, M>(
make_input: M,
Expand Down
2 changes: 1 addition & 1 deletion src/ast/parsing/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ where
.as_context();

let store_a_to_const_addr = const_expr_p(make_input)
.nested_in(nested_brace_content_p(make_input))
.nested_in(nested_bracket_content_p(make_input))
.then_ignore(equal_p())
.then_ignore(kw_a_p())
.map(Statement::StoreAToConstAddress)
Expand Down

0 comments on commit dade1ea

Please sign in to comment.