mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Be more lenient with indentation in record parsing
... and extract a shared helper with collection_trailing_sep_e, thereby resolving some inconsistencies with normal collection parsing. ... and delete some dead code while I'm at it
This commit is contained in:
parent
6bdab37541
commit
07ebc81cba
9 changed files with 202 additions and 225 deletions
|
@ -0,0 +1,5 @@
|
|||
x = foo {
|
||||
bar
|
||||
: blah,
|
||||
}
|
||||
x
|
|
@ -0,0 +1,72 @@
|
|||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
Index(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-22,
|
||||
],
|
||||
space_before: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
space_after: [
|
||||
Slice(start = 0, length = 0),
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@0-1 Identifier(
|
||||
"x",
|
||||
),
|
||||
@4-22 Apply(
|
||||
@4-7 Var {
|
||||
module_name: "",
|
||||
ident: "foo",
|
||||
},
|
||||
[
|
||||
@8-22 Record(
|
||||
[
|
||||
@10-20 SpaceBefore(
|
||||
SpaceAfter(
|
||||
RequiredValue(
|
||||
@10-13 "bar",
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
@16-20 SpaceBefore(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "blah",
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
Space,
|
||||
),
|
||||
),
|
||||
],
|
||||
},
|
||||
@23-24 SpaceBefore(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "x",
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
)
|
|
@ -0,0 +1,6 @@
|
|||
x = foo {
|
||||
bar
|
||||
:
|
||||
blah
|
||||
}
|
||||
x
|
|
@ -26,9 +26,9 @@ Defs(
|
|||
},
|
||||
[
|
||||
@8-23 Record(
|
||||
Collection {
|
||||
items: [
|
||||
@12-21 SpaceBefore(
|
||||
[
|
||||
@12-21 SpaceBefore(
|
||||
SpaceAfter(
|
||||
RequiredValue(
|
||||
@12-15 "bar",
|
||||
[],
|
||||
|
@ -41,11 +41,11 @@ Defs(
|
|||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
final_comments: [
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
Space,
|
||||
|
|
|
@ -193,15 +193,15 @@ mod test_snapshots {
|
|||
fail/list_without_end.expr,
|
||||
fail/multi_no_end.expr,
|
||||
fail/pattern_binds_keyword.expr,
|
||||
fail/pattern_in_parens_end_comma.expr,
|
||||
fail/pattern_in_parens_end.expr,
|
||||
fail/pattern_in_parens_end_comma.expr,
|
||||
fail/pattern_in_parens_indent_open.expr,
|
||||
fail/pattern_in_parens_open.expr,
|
||||
fail/record_type_end.expr,
|
||||
fail/record_type_keyword_field_name.expr,
|
||||
fail/record_type_missing_comma.expr,
|
||||
fail/record_type_open_indent.expr,
|
||||
fail/record_type_open.expr,
|
||||
fail/record_type_open_indent.expr,
|
||||
fail/record_type_tab.expr,
|
||||
fail/single_no_end.expr,
|
||||
fail/tab_crash.header,
|
||||
|
@ -270,13 +270,13 @@ mod test_snapshots {
|
|||
pass/empty_platform_header.header,
|
||||
pass/empty_record.expr,
|
||||
pass/empty_string.expr,
|
||||
pass/equals_with_spaces.expr,
|
||||
pass/equals.expr,
|
||||
pass/expect_fx.moduledefs,
|
||||
pass/equals_with_spaces.expr,
|
||||
pass/expect.expr,
|
||||
pass/expect_fx.moduledefs,
|
||||
pass/float_with_underscores.expr,
|
||||
pass/full_app_header_trailing_commas.header,
|
||||
pass/full_app_header.header,
|
||||
pass/full_app_header_trailing_commas.header,
|
||||
pass/function_effect_types.header,
|
||||
pass/function_with_tuple_ext_type.expr,
|
||||
pass/function_with_tuple_type.expr,
|
||||
|
@ -305,8 +305,8 @@ mod test_snapshots {
|
|||
pass/multi_char_string.expr,
|
||||
pass/multiline_string.expr,
|
||||
pass/multiline_tuple_with_comments.expr,
|
||||
pass/multiline_type_signature_with_comment.expr,
|
||||
pass/multiline_type_signature.expr,
|
||||
pass/multiline_type_signature_with_comment.expr,
|
||||
pass/multiple_fields.expr,
|
||||
pass/multiple_operators.expr,
|
||||
pass/neg_inf_float.expr,
|
||||
|
@ -338,14 +338,15 @@ mod test_snapshots {
|
|||
pass/one_spaced_def.expr,
|
||||
pass/opaque_destructure_first_item_in_body.expr,
|
||||
pass/opaque_has_abilities.expr,
|
||||
pass/opaque_reference_expr_with_arguments.expr,
|
||||
pass/opaque_reference_expr.expr,
|
||||
pass/opaque_reference_pattern_with_arguments.expr,
|
||||
pass/opaque_reference_expr_with_arguments.expr,
|
||||
pass/opaque_reference_pattern.expr,
|
||||
pass/opaque_reference_pattern_with_arguments.expr,
|
||||
pass/opaque_simple.moduledefs,
|
||||
pass/opaque_with_type_arguments.moduledefs,
|
||||
pass/ops_with_newlines.expr,
|
||||
pass/outdented_app_with_record.expr,
|
||||
pass/outdented_colon_in_record.expr,
|
||||
pass/outdented_list.expr,
|
||||
pass/outdented_record.expr,
|
||||
pass/packed_singleton_list.expr,
|
||||
|
@ -389,8 +390,8 @@ mod test_snapshots {
|
|||
pass/three_arg_closure.expr,
|
||||
pass/tuple_access_after_record.expr,
|
||||
pass/tuple_accessor_function.expr,
|
||||
pass/tuple_type_ext.expr,
|
||||
pass/tuple_type.expr,
|
||||
pass/tuple_type_ext.expr,
|
||||
pass/two_arg_closure.expr,
|
||||
pass/two_backpassing.expr,
|
||||
pass/two_branch_when.expr,
|
||||
|
@ -398,12 +399,12 @@ mod test_snapshots {
|
|||
pass/type_decl_with_underscore.expr,
|
||||
pass/type_signature_def.expr,
|
||||
pass/type_signature_function_def.expr,
|
||||
pass/unary_negation.expr,
|
||||
pass/unary_negation_access.expr, // Regression test for https://github.com/roc-lang/roc/issues/509
|
||||
pass/unary_negation_arg.expr,
|
||||
pass/unary_negation_with_parens.expr,
|
||||
pass/unary_negation.expr,
|
||||
pass/unary_not_with_parens.expr,
|
||||
pass/unary_not.expr,
|
||||
pass/unary_not_with_parens.expr,
|
||||
pass/underscore_backpassing.expr,
|
||||
pass/underscore_in_assignment_pattern.expr,
|
||||
pass/var_else.expr,
|
||||
|
@ -414,10 +415,10 @@ mod test_snapshots {
|
|||
pass/var_when.expr,
|
||||
pass/when_if_guard.expr,
|
||||
pass/when_in_assignment.expr,
|
||||
pass/when_in_function_python_style_indent.expr,
|
||||
pass/when_in_function.expr,
|
||||
pass/when_in_parens_indented.expr,
|
||||
pass/when_in_function_python_style_indent.expr,
|
||||
pass/when_in_parens.expr,
|
||||
pass/when_in_parens_indented.expr,
|
||||
pass/when_with_alternative_patterns.expr,
|
||||
pass/when_with_function_application.expr,
|
||||
pass/when_with_negative_numbers.expr,
|
||||
|
@ -427,8 +428,8 @@ mod test_snapshots {
|
|||
pass/when_with_tuples.expr,
|
||||
pass/where_clause_function.expr,
|
||||
pass/where_clause_multiple_bound_abilities.expr,
|
||||
pass/where_clause_multiple_has_across_newlines.expr,
|
||||
pass/where_clause_multiple_has.expr,
|
||||
pass/where_clause_multiple_has_across_newlines.expr,
|
||||
pass/where_clause_non_function.expr,
|
||||
pass/where_clause_on_newline.expr,
|
||||
pass/zero_float.expr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue