mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-01 21:40:58 +00:00
Parens and Commas application syntax
This commit is contained in:
parent
91ed6a5a8e
commit
af39ce57fb
36 changed files with 438 additions and 154 deletions
|
|
@ -0,0 +1 @@
|
|||
Whee(12, 34)
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
@0-12 SpaceAfter(
|
||||
Apply(
|
||||
@0-4 Tag(
|
||||
"Whee",
|
||||
),
|
||||
[
|
||||
@5-7 Num(
|
||||
"12",
|
||||
),
|
||||
@9-11 Num(
|
||||
"34",
|
||||
),
|
||||
],
|
||||
ParensAndCommas,
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1 @@
|
|||
Whee(12, 34)
|
||||
|
|
@ -0,0 +1 @@
|
|||
whee(12, 34)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
@0-13 SpaceAfter(
|
||||
Apply(
|
||||
@0-4 Var {
|
||||
module_name: "",
|
||||
ident: "whee",
|
||||
},
|
||||
[
|
||||
@5-7 Num(
|
||||
"12",
|
||||
),
|
||||
@10-12 Num(
|
||||
"34",
|
||||
),
|
||||
],
|
||||
ParensAndCommas,
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1 @@
|
|||
whee(12, 34)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
@0-8 SpaceAfter(
|
||||
@0-9 SpaceAfter(
|
||||
BinOps(
|
||||
[
|
||||
(
|
||||
|
|
@ -8,24 +8,24 @@
|
|||
@1-2 LessThan,
|
||||
),
|
||||
],
|
||||
@2-7 Apply(
|
||||
@2-8 Apply(
|
||||
@2-3 Var {
|
||||
module_name: "",
|
||||
ident: "l",
|
||||
},
|
||||
[
|
||||
@4-7 ParensAround(
|
||||
@5-8 ParensAround(
|
||||
BinOps(
|
||||
[
|
||||
(
|
||||
@4-5 Var {
|
||||
@5-6 Var {
|
||||
module_name: "",
|
||||
ident: "r",
|
||||
},
|
||||
@5-6 Star,
|
||||
@6-7 Star,
|
||||
),
|
||||
],
|
||||
@6-7 Tag(
|
||||
@7-8 Tag(
|
||||
"N",
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
N<l(r*N)
|
||||
N<l (r*N)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
combine(
|
||||
mix(vodka, gin),
|
||||
Juices({
|
||||
color: Colors.orange,
|
||||
flavor: Flavors.orange,
|
||||
amount: 1 + 2,
|
||||
}),
|
||||
)
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
@0-109 SpaceAfter(
|
||||
Apply(
|
||||
@0-7 Var {
|
||||
module_name: "",
|
||||
ident: "combine",
|
||||
},
|
||||
[
|
||||
@8-23 Apply(
|
||||
@8-11 Var {
|
||||
module_name: "",
|
||||
ident: "mix",
|
||||
},
|
||||
[
|
||||
@12-17 Var {
|
||||
module_name: "",
|
||||
ident: "vodka",
|
||||
},
|
||||
@19-22 Var {
|
||||
module_name: "",
|
||||
ident: "gin",
|
||||
},
|
||||
],
|
||||
ParensAndCommas,
|
||||
),
|
||||
@25-108 Apply(
|
||||
@25-31 Tag(
|
||||
"Juices",
|
||||
),
|
||||
[
|
||||
@32-107 Record(
|
||||
[
|
||||
@38-58 SpaceBefore(
|
||||
RequiredValue(
|
||||
@38-43 "color",
|
||||
[],
|
||||
@45-58 Var {
|
||||
module_name: "Colors",
|
||||
ident: "orange",
|
||||
},
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
@64-86 SpaceBefore(
|
||||
RequiredValue(
|
||||
@64-70 "flavor",
|
||||
[],
|
||||
@72-86 Var {
|
||||
module_name: "Flavors",
|
||||
ident: "orange",
|
||||
},
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
@92-105 SpaceBefore(
|
||||
SpaceAfter(
|
||||
RequiredValue(
|
||||
@92-98 "amount",
|
||||
[],
|
||||
@100-105 BinOps(
|
||||
[
|
||||
(
|
||||
@100-101 Num(
|
||||
"1",
|
||||
),
|
||||
@102-103 Plus,
|
||||
),
|
||||
],
|
||||
@104-105 Num(
|
||||
"2",
|
||||
),
|
||||
),
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
ParensAndCommas,
|
||||
),
|
||||
],
|
||||
ParensAndCommas,
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
combine(mix(vodka, gin), Juices({
|
||||
color: Colors.orange,
|
||||
flavor: Flavors.orange,
|
||||
amount: 1 + 2
|
||||
}))
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
@0-21 SpaceAfter(
|
||||
@0-24 SpaceAfter(
|
||||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(0),
|
||||
],
|
||||
regions: [
|
||||
@0-19,
|
||||
@0-22,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
|
|
@ -19,18 +19,18 @@
|
|||
header: TypeHeader {
|
||||
name: @0-1 "N",
|
||||
vars: [
|
||||
@2-12 Identifier {
|
||||
@3-13 Identifier {
|
||||
ident: "implements",
|
||||
},
|
||||
@13-14 Identifier {
|
||||
@15-16 Identifier {
|
||||
ident: "h",
|
||||
},
|
||||
@15-16 NumLiteral(
|
||||
@18-19 NumLiteral(
|
||||
"0",
|
||||
),
|
||||
],
|
||||
},
|
||||
ann: @18-19 Apply(
|
||||
ann: @21-22 Apply(
|
||||
"",
|
||||
"B",
|
||||
[],
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
],
|
||||
value_defs: [],
|
||||
},
|
||||
@20-21 SpaceBefore(
|
||||
@23-24 SpaceBefore(
|
||||
Tag(
|
||||
"T",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
N(implements)h(0):B
|
||||
N (implements) h (0):B
|
||||
T
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
@0-16 SpaceAfter(
|
||||
@0-18 SpaceAfter(
|
||||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-14,
|
||||
@0-16,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
|
|
@ -22,27 +22,27 @@
|
|||
ident: "u",
|
||||
},
|
||||
[
|
||||
@2-11 Apply(
|
||||
@2-8 StrLiteral(
|
||||
@3-13 Apply(
|
||||
@3-9 StrLiteral(
|
||||
Block(
|
||||
[],
|
||||
),
|
||||
),
|
||||
[
|
||||
@9-10 NumLiteral(
|
||||
@11-12 NumLiteral(
|
||||
"0",
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
@13-14 BoundVariable(
|
||||
@15-16 BoundVariable(
|
||||
"f",
|
||||
),
|
||||
),
|
||||
],
|
||||
},
|
||||
@15-16 SpaceBefore(
|
||||
@17-18 SpaceBefore(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "s",
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
u(""""""(0)):f
|
||||
u ("""""" (0)):f
|
||||
s
|
||||
|
|
|
|||
|
|
@ -1,52 +1,57 @@
|
|||
@0-12 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(0),
|
||||
],
|
||||
regions: [
|
||||
@0-10,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [
|
||||
Alias {
|
||||
header: TypeHeader {
|
||||
name: @0-2 "Zx",
|
||||
vars: [
|
||||
@3-4 SpaceAfter(
|
||||
Identifier {
|
||||
ident: "e",
|
||||
@0-13 SpaceAfter(
|
||||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(0),
|
||||
],
|
||||
regions: [
|
||||
@0-11,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [
|
||||
Alias {
|
||||
header: TypeHeader {
|
||||
name: @0-2 "Zx",
|
||||
vars: [
|
||||
@4-5 SpaceAfter(
|
||||
Identifier {
|
||||
ident: "e",
|
||||
},
|
||||
[
|
||||
LineComment(
|
||||
"",
|
||||
),
|
||||
],
|
||||
),
|
||||
@8-9 Identifier {
|
||||
ident: "f",
|
||||
},
|
||||
[
|
||||
LineComment(
|
||||
"",
|
||||
),
|
||||
],
|
||||
),
|
||||
@7-8 Identifier {
|
||||
ident: "f",
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
ann: @10-11 BoundVariable(
|
||||
"i",
|
||||
),
|
||||
},
|
||||
ann: @9-10 BoundVariable(
|
||||
"i",
|
||||
),
|
||||
},
|
||||
],
|
||||
value_defs: [],
|
||||
},
|
||||
@11-12 SpaceBefore(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "s",
|
||||
],
|
||||
value_defs: [],
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
@12-13 SpaceBefore(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "s",
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
Zx(e#
|
||||
Zx (e#
|
||||
)f:i
|
||||
s
|
||||
s
|
||||
|
|
|
|||
|
|
@ -1,49 +1,54 @@
|
|||
@0-10 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(0),
|
||||
],
|
||||
regions: [
|
||||
@0-8,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [
|
||||
Alias {
|
||||
header: TypeHeader {
|
||||
name: @0-1 "U",
|
||||
vars: [
|
||||
@2-5 Apply(
|
||||
@2-3 Identifier {
|
||||
ident: "b",
|
||||
},
|
||||
[
|
||||
@4-5 Identifier {
|
||||
ident: "a",
|
||||
@0-11 SpaceAfter(
|
||||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(0),
|
||||
],
|
||||
regions: [
|
||||
@0-9,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [
|
||||
Alias {
|
||||
header: TypeHeader {
|
||||
name: @0-1 "U",
|
||||
vars: [
|
||||
@3-6 Apply(
|
||||
@3-4 Identifier {
|
||||
ident: "b",
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
[
|
||||
@5-6 Identifier {
|
||||
ident: "a",
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
},
|
||||
ann: @8-9 BoundVariable(
|
||||
"b",
|
||||
),
|
||||
},
|
||||
ann: @7-8 BoundVariable(
|
||||
"b",
|
||||
),
|
||||
},
|
||||
],
|
||||
value_defs: [],
|
||||
},
|
||||
@9-10 SpaceBefore(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "a",
|
||||
],
|
||||
value_defs: [],
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
@10-11 SpaceBefore(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "a",
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
U(b a):b
|
||||
a
|
||||
U (b a):b
|
||||
a
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
@0-15 SpaceAfter(
|
||||
@0-16 SpaceAfter(
|
||||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(0),
|
||||
],
|
||||
regions: [
|
||||
@0-13,
|
||||
@0-14,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
|
|
@ -19,14 +19,14 @@
|
|||
header: TypeHeader {
|
||||
name: @0-1 "Q",
|
||||
vars: [
|
||||
@2-10 Apply(
|
||||
@2-8 StrLiteral(
|
||||
@3-11 Apply(
|
||||
@3-9 StrLiteral(
|
||||
Block(
|
||||
[],
|
||||
),
|
||||
),
|
||||
[
|
||||
@8-10 StrLiteral(
|
||||
@9-11 StrLiteral(
|
||||
PlainLine(
|
||||
"",
|
||||
),
|
||||
|
|
@ -35,14 +35,14 @@
|
|||
),
|
||||
],
|
||||
},
|
||||
ann: @12-13 BoundVariable(
|
||||
ann: @13-14 BoundVariable(
|
||||
"a",
|
||||
),
|
||||
},
|
||||
],
|
||||
value_defs: [],
|
||||
},
|
||||
@14-15 SpaceBefore(
|
||||
@15-16 SpaceBefore(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "q",
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
Q(""""""""):a
|
||||
Q (""""""""):a
|
||||
q
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
@0-31 SpaceAfter(
|
||||
@0-32 SpaceAfter(
|
||||
Apply(
|
||||
@0-3 Var {
|
||||
module_name: "",
|
||||
ident: "il3",
|
||||
},
|
||||
[
|
||||
@3-31 Closure(
|
||||
@3-32 Closure(
|
||||
[
|
||||
@4-5 Identifier {
|
||||
ident: "k",
|
||||
},
|
||||
],
|
||||
@13-31 SpaceBefore(
|
||||
@13-32 SpaceBefore(
|
||||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(0),
|
||||
],
|
||||
regions: [
|
||||
@13-28,
|
||||
@13-29,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
|
|
@ -35,13 +35,13 @@
|
|||
@16-18 OpaqueRef(
|
||||
"@C",
|
||||
),
|
||||
@22-25 SpaceBefore(
|
||||
@23-26 SpaceBefore(
|
||||
Apply(
|
||||
@22-24 Identifier {
|
||||
@23-25 Identifier {
|
||||
ident: "t!",
|
||||
},
|
||||
[
|
||||
@24-25 Tag(
|
||||
@25-26 Tag(
|
||||
"K",
|
||||
),
|
||||
],
|
||||
|
|
@ -54,14 +54,14 @@
|
|||
),
|
||||
],
|
||||
},
|
||||
ann: @27-28 BoundVariable(
|
||||
ann: @28-29 BoundVariable(
|
||||
"i",
|
||||
),
|
||||
},
|
||||
],
|
||||
value_defs: [],
|
||||
},
|
||||
@30-31 SpaceBefore(
|
||||
@31-32 SpaceBefore(
|
||||
Tag(
|
||||
"C",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
il3\k->#w#z
|
||||
CCC@C(#i
|
||||
CCC@C (#i
|
||||
t!K):i
|
||||
C
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ mod test_fmt {
|
|||
Ok((actual, state)) => {
|
||||
use roc_parse::normalize::Normalize;
|
||||
|
||||
let flags = MigrationFlags::new(false);
|
||||
let flags = MigrationFlags::new(false, false);
|
||||
let mut buf = Buf::new_in(&arena, flags);
|
||||
|
||||
fmt_module_and_defs(&arena, src, &actual, state, &mut buf);
|
||||
|
|
@ -3497,6 +3497,48 @@ mod test_fmt {
|
|||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn single_line_application_with_parens() {
|
||||
expr_formats_same(indoc!(
|
||||
r"
|
||||
combine(peanut_butter, chocolate)
|
||||
"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn single_line_nested_application_with_parens() {
|
||||
expr_formats_same(indoc!(
|
||||
r"
|
||||
combine(combine(peanut_butter, honey), chocolate)
|
||||
"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multi_line_application_with_parens() {
|
||||
expr_formats_same(indoc!(
|
||||
r"
|
||||
combine(
|
||||
peanut_butter,
|
||||
chocolate,
|
||||
)
|
||||
"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multi_line_nested_application_with_parens() {
|
||||
expr_formats_same(indoc!(
|
||||
r"
|
||||
combine(
|
||||
combine(peanut_butter, honey),
|
||||
chocolate,
|
||||
)
|
||||
"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn partial_multi_line_application() {
|
||||
expr_formats_to(
|
||||
|
|
|
|||
|
|
@ -323,9 +323,11 @@ mod test_snapshots {
|
|||
pass/apply_record_ann.expr,
|
||||
pass/apply_record_parens_newline_field.expr,
|
||||
pass/apply_tag.expr,
|
||||
pass/apply_tag_pnc.expr,
|
||||
pass/apply_three_args.expr,
|
||||
pass/apply_tuple_ext_parens_ty.expr,
|
||||
pass/apply_two_args.expr,
|
||||
pass/apply_two_args_pnc.expr,
|
||||
pass/apply_unary_negation.expr,
|
||||
pass/apply_unary_not.expr,
|
||||
pass/arg_pattern_as.expr,
|
||||
|
|
@ -479,6 +481,7 @@ mod test_snapshots {
|
|||
pass/list_minus_newlines.expr,
|
||||
pass/list_pattern_weird_indent.expr,
|
||||
pass/list_patterns.expr,
|
||||
pass/long_complex_application_with_pnc.expr,
|
||||
pass/looks_like_implements.expr,
|
||||
pass/lowest_float.expr,
|
||||
pass/lowest_int.expr,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue