Skip to content

Commit 4ef61c8

Browse files
committed
chore: Code readability improvements to opt_second_expression
1 parent 9d37097 commit 4ef61c8

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

rusty_parser/src/specific/core/opt_second_expression.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,22 @@ where
2323
first_parser.chain(
2424
move |first| {
2525
let is_paren = is_first_wrapped_in_parenthesis(&first);
26-
parse_second(keyword, is_paren)
26+
parse_second(keyword, is_paren).to_option()
2727
},
2828
|first, opt_second| (first, opt_second),
2929
)
3030
}
3131

32+
// first_parser AND [ cond_ws(is_first_paren) KEYWORD !AND! ws_expr ]
3233
fn parse_second(
3334
k: Keyword,
34-
is_paren: bool,
35-
) -> impl Parser<RcStringView, Output = Option<ExpressionPos>> {
36-
conditionally_opt_whitespace(is_paren)
37-
.and_tuple(keyword(k))
38-
.and_without_undo_keep_right(ws_expr_pos_p().or_fail(err(k)))
39-
.to_option()
35+
is_preceded_by_paren: bool,
36+
) -> impl Parser<RcStringView, Output = ExpressionPos> {
37+
ws_keyword(k, is_preceded_by_paren).and_without_undo_keep_right(ws_expr_pos_p().or_fail(err(k)))
38+
}
39+
40+
fn ws_keyword(k: Keyword, is_preceded_by_paren: bool) -> impl Parser<RcStringView> {
41+
conditionally_opt_whitespace(is_preceded_by_paren).and_tuple(keyword(k))
4042
}
4143

4244
fn err(keyword: Keyword) -> ParseError {

0 commit comments

Comments
 (0)