move when and if into expression

This commit is contained in:
Folkert 2021-03-07 19:50:32 +01:00
parent 1b750149c0
commit 7f7593f63e
2 changed files with 9 additions and 6 deletions

View file

@ -322,12 +322,9 @@ fn loc_parse_expr_body_without_operators_help<'a>(
loc_expr_in_parens_etc_help(min_indent), loc_expr_in_parens_etc_help(min_indent),
loc!(specialize(EExpr::Str, string_literal_help())), loc!(specialize(EExpr::Str, string_literal_help())),
loc!(specialize(EExpr::Number, number_literal_help())), loc!(specialize(EExpr::Number, number_literal_help())),
loc!(specialize(EExpr::Lambda, closure_help(min_indent))),
loc!(record_literal_help(min_indent)), loc!(record_literal_help(min_indent)),
loc!(specialize(EExpr::List, list_literal_help(min_indent))), loc!(specialize(EExpr::List, list_literal_help(min_indent))),
loc!(unary_op_help(min_indent)), loc!(unary_op_help(min_indent)),
loc!(specialize(EExpr::When, when::expr_help(min_indent))),
loc!(specialize(EExpr::If, if_expr_help(min_indent))),
loc!(ident_etc_help(min_indent)), loc!(ident_etc_help(min_indent)),
fail_expr_start_e() fail_expr_start_e()
) )
@ -436,8 +433,14 @@ fn parse_expr_help<'a>(
arena: &'a Bump, arena: &'a Bump,
state: State<'a>, state: State<'a>,
) -> ParseResult<'a, Expr<'a>, EExpr<'a>> { ) -> ParseResult<'a, Expr<'a>, EExpr<'a>> {
let (_, loc_expr1, state) = let (_, loc_expr1, state) = one_of![
loc_parse_expr_body_without_operators_help(min_indent, arena, state)?; |arena, state| loc_parse_expr_body_without_operators_help(min_indent, arena, state),
loc!(specialize(EExpr::If, if_expr_help(min_indent))),
loc!(specialize(EExpr::When, when::expr_help(min_indent))),
loc!(specialize(EExpr::Lambda, closure_help(min_indent))),
fail_expr_start_e()
]
.parse(arena, state)?;
let initial = state.clone(); let initial = state.clone();

View file

@ -244,7 +244,7 @@ fn to_expr_report<'a>(
alloc.concat(vec![ alloc.concat(vec![
alloc.reflow("The has-type operator "), alloc.reflow("The has-type operator "),
alloc.parser_suggestion(":"), alloc.parser_suggestion(":"),
alloc.reflow(" can only occur in a definition's type signature, like "), alloc.reflow(" can only occur in a definition's type signature, like"),
]), ]),
alloc alloc
.vcat(vec![ .vcat(vec![