mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
add nested snapshot for suffixed expr
This commit is contained in:
parent
8bbbd768ec
commit
e2557067c8
7 changed files with 65 additions and 4 deletions
|
@ -513,7 +513,10 @@ impl<'a> Formattable for Expr<'a> {
|
|||
MultipleRecordBuilders { .. } => {}
|
||||
UnappliedRecordBuilder { .. } => {}
|
||||
IngestedFile(_, _) => {}
|
||||
Suffixed(sub_expr) => sub_expr.format_with_options(buf, parens, newlines, indent),
|
||||
Suffixed(sub_expr) => {
|
||||
sub_expr.format_with_options(buf, parens, newlines, indent);
|
||||
buf.push('!');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -311,8 +311,20 @@ fn expr_start<'a>(options: ExprParseOptions) -> impl Parser<'a, Loc<Expr<'a>>, E
|
|||
|
||||
fn expr_operator_chain<'a>(options: ExprParseOptions) -> impl Parser<'a, Expr<'a>, EExpr<'a>> {
|
||||
line_min_indent(move |arena, state: State<'a>, min_indent: u32| {
|
||||
let (_, expr, state) =
|
||||
loc_possibly_negative_or_negated_term(options).parse(arena, state, min_indent)?;
|
||||
let (_, expr, state) = loc_possibly_negative_or_negated_term(options)
|
||||
.parse(arena, state, min_indent)
|
||||
.map(|(progress, expr, state)| {
|
||||
// If the next thing after the expression is a `!`, then it's Suffixed
|
||||
if state.bytes().starts_with(b"!") {
|
||||
(
|
||||
progress,
|
||||
Loc::at(expr.region, Expr::Suffixed(arena.alloc(expr.value))),
|
||||
state.advance(1),
|
||||
)
|
||||
} else {
|
||||
(progress, expr, state)
|
||||
}
|
||||
})?;
|
||||
|
||||
let initial_state = state.clone();
|
||||
let end = state.pos();
|
||||
|
|
|
@ -1 +1 @@
|
|||
Stdout.line
|
||||
Stdout.line!
|
|
@ -0,0 +1 @@
|
|||
foo! (bar! baz) (blah stuff)
|
|
@ -0,0 +1,43 @@
|
|||
Apply(
|
||||
@0-3 Suffixed(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
),
|
||||
[
|
||||
@9-17 ParensAround(
|
||||
Apply(
|
||||
@9-12 Suffixed(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "bar",
|
||||
},
|
||||
),
|
||||
[
|
||||
@14-17 Var {
|
||||
module_name: "",
|
||||
ident: "baz",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
),
|
||||
@22-32 ParensAround(
|
||||
Apply(
|
||||
@22-26 Var {
|
||||
module_name: "",
|
||||
ident: "blah",
|
||||
},
|
||||
[
|
||||
@27-32 Var {
|
||||
module_name: "",
|
||||
ident: "stuff",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
),
|
||||
],
|
||||
Space,
|
||||
)
|
|
@ -0,0 +1 @@
|
|||
foo! ( bar! baz) ( blah stuff)
|
|
@ -442,6 +442,7 @@ mod test_snapshots {
|
|||
pass/sub_var_with_spaces.expr,
|
||||
pass/sub_with_spaces.expr,
|
||||
pass/suffixed.expr,
|
||||
pass/suffixed_nested.expr,
|
||||
pass/tag_pattern.expr,
|
||||
pass/ten_times_eleven.expr,
|
||||
pass/three_arg_closure.expr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue