diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 92c68b12b..97f9e9b42 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -1479,6 +1479,46 @@ } } }, + "ExitStmt": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "exit" + }, + { + "kind": "recurse_field", + "field": "f_loop_name" + }, + { + "kind": "recurse_field", + "field": "f_cond_expr" + }, + { + "kind": "text", + "text": ";" + } + ] + }, + "fields": { + "f_cond_expr": [ + "whitespace", + { + "kind": "text", + "text": "when" + }, + { + "kind": "align", + "width": 2, + "contents": [ + "line", + "recurse" + ] + } + ] + } + }, "ExprFunction": { "node": { "kind": "group", @@ -1749,6 +1789,30 @@ "document": "recurse" } }, + "GotoStmt": { + "node": { + "kind": "group", + "document": { + "kind": "align", + "width": 2, + "contents": [ + { + "kind": "text", + "text": "goto" + }, + "line", + { + "kind": "recurse_field", + "field": "f_label_name" + }, + { + "kind": "text", + "text": ";" + } + ] + } + } + }, "ForLoopIterFilter": { "node": { "kind": "group", @@ -2567,6 +2631,26 @@ ] } }, + "NamedStmt": { + "node": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_decl" + }, + { + "kind": "text", + "text": ":" + }, + "hardlineWithoutBreakParent", + { + "kind": "recurse_field", + "field": "f_stmt" + } + ] + } + }, "NameList": { "sep": [ "recurse", diff --git a/testsuite/tests/unparsing/exit_stmt/long/doc-baseline.json b/testsuite/tests/unparsing/exit_stmt/long/doc-baseline.json new file mode 100644 index 000000000..b398d0d59 --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/long/doc-baseline.json @@ -0,0 +1,104 @@ +{ + "id": 13, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 12, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "exit Quuux when" + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "Foooooooooooooooooooooooooooooooooooooooooooooooooooooo" + }, + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 4, + "kind": "text", + "text": "and then " + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 5, + "kind": "text", + "text": "Baaaaaaaaaar" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 11, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/exit_stmt/long/input.ada b/testsuite/tests/unparsing/exit_stmt/long/input.ada new file mode 100644 index 000000000..e9d9a44b3 --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/long/input.ada @@ -0,0 +1,2 @@ +exit Quuux when Foooooooooooooooooooooooooooooooooooooooooooooooooooooo and then Baaaaaaaaaar; + diff --git a/testsuite/tests/unparsing/exit_stmt/long/test.out b/testsuite/tests/unparsing/exit_stmt/long/test.out new file mode 100644 index 000000000..0e2434c3a --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/long/test.out @@ -0,0 +1,3 @@ +exit Quuux when + Foooooooooooooooooooooooooooooooooooooooooooooooooooooo + and then Baaaaaaaaaar; diff --git a/testsuite/tests/unparsing/exit_stmt/long/test.yaml b/testsuite/tests/unparsing/exit_stmt/long/test.yaml new file mode 100644 index 000000000..c38604ac7 --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/long/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: exit_stmt +description: | + Test the line break after the `when` keyword and the continuation line + indentation of `f_cond_expr`. diff --git a/testsuite/tests/unparsing/exit_stmt/no_when/doc-baseline.json b/testsuite/tests/unparsing/exit_stmt/no_when/doc-baseline.json new file mode 100644 index 000000000..d0fb4dd60 --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/no_when/doc-baseline.json @@ -0,0 +1,21 @@ +{ + "id": 2, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 1, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "exit;" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/exit_stmt/no_when/input.ada b/testsuite/tests/unparsing/exit_stmt/no_when/input.ada new file mode 100644 index 000000000..f7aa5b039 --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/no_when/input.ada @@ -0,0 +1 @@ +exit; diff --git a/testsuite/tests/unparsing/exit_stmt/no_when/test.out b/testsuite/tests/unparsing/exit_stmt/no_when/test.out new file mode 100644 index 000000000..f7aa5b039 --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/no_when/test.out @@ -0,0 +1 @@ +exit; diff --git a/testsuite/tests/unparsing/exit_stmt/no_when/test.yaml b/testsuite/tests/unparsing/exit_stmt/no_when/test.yaml new file mode 100644 index 000000000..29cc246d9 --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/no_when/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: exit_stmt +description: | + Test that no line breaks were added. diff --git a/testsuite/tests/unparsing/exit_stmt/short/doc-baseline.json b/testsuite/tests/unparsing/exit_stmt/short/doc-baseline.json new file mode 100644 index 000000000..8e2b94f59 --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/short/doc-baseline.json @@ -0,0 +1,58 @@ +{ + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "exit when" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "Foo" + } + ] + } + } + }, + { + "id": 5, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/exit_stmt/short/input.ada b/testsuite/tests/unparsing/exit_stmt/short/input.ada new file mode 100644 index 000000000..182e9b8eb --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/short/input.ada @@ -0,0 +1 @@ +exit when Foo; diff --git a/testsuite/tests/unparsing/exit_stmt/short/test.out b/testsuite/tests/unparsing/exit_stmt/short/test.out new file mode 100644 index 000000000..182e9b8eb --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/short/test.out @@ -0,0 +1 @@ +exit when Foo; diff --git a/testsuite/tests/unparsing/exit_stmt/short/test.yaml b/testsuite/tests/unparsing/exit_stmt/short/test.yaml new file mode 100644 index 000000000..29cc246d9 --- /dev/null +++ b/testsuite/tests/unparsing/exit_stmt/short/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: exit_stmt +description: | + Test that no line breaks were added. diff --git a/testsuite/tests/unparsing/goto_stmt/long/doc-baseline.json b/testsuite/tests/unparsing/goto_stmt/long/doc-baseline.json new file mode 100644 index 000000000..2245bca1f --- /dev/null +++ b/testsuite/tests/unparsing/goto_stmt/long/doc-baseline.json @@ -0,0 +1,47 @@ +{ + "id": 5, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "goto" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo;" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/goto_stmt/long/input.ada b/testsuite/tests/unparsing/goto_stmt/long/input.ada new file mode 100644 index 000000000..5dac814a9 --- /dev/null +++ b/testsuite/tests/unparsing/goto_stmt/long/input.ada @@ -0,0 +1 @@ +goto Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo; diff --git a/testsuite/tests/unparsing/goto_stmt/long/test.out b/testsuite/tests/unparsing/goto_stmt/long/test.out new file mode 100644 index 000000000..60aa6c3fd --- /dev/null +++ b/testsuite/tests/unparsing/goto_stmt/long/test.out @@ -0,0 +1,2 @@ +goto + Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo; diff --git a/testsuite/tests/unparsing/goto_stmt/long/test.yaml b/testsuite/tests/unparsing/goto_stmt/long/test.yaml new file mode 100644 index 000000000..c701c95bd --- /dev/null +++ b/testsuite/tests/unparsing/goto_stmt/long/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: goto_stmt +description: | + Test the line break after the `goto` keyword and the continuation line + indentation of `f_label_name`. diff --git a/testsuite/tests/unparsing/goto_stmt/short/doc-baseline.json b/testsuite/tests/unparsing/goto_stmt/short/doc-baseline.json new file mode 100644 index 000000000..e94ce1440 --- /dev/null +++ b/testsuite/tests/unparsing/goto_stmt/short/doc-baseline.json @@ -0,0 +1,47 @@ +{ + "id": 5, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "goto" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "Foo;" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/goto_stmt/short/input.ada b/testsuite/tests/unparsing/goto_stmt/short/input.ada new file mode 100644 index 000000000..baf635dda --- /dev/null +++ b/testsuite/tests/unparsing/goto_stmt/short/input.ada @@ -0,0 +1 @@ +goto Foo; diff --git a/testsuite/tests/unparsing/goto_stmt/short/test.out b/testsuite/tests/unparsing/goto_stmt/short/test.out new file mode 100644 index 000000000..baf635dda --- /dev/null +++ b/testsuite/tests/unparsing/goto_stmt/short/test.out @@ -0,0 +1 @@ +goto Foo; diff --git a/testsuite/tests/unparsing/goto_stmt/short/test.yaml b/testsuite/tests/unparsing/goto_stmt/short/test.yaml new file mode 100644 index 000000000..bb02aca60 --- /dev/null +++ b/testsuite/tests/unparsing/goto_stmt/short/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: goto_stmt +description: | + Test that no line breaks were added. diff --git a/testsuite/tests/unparsing/named_stmt/doc-baseline.json b/testsuite/tests/unparsing/named_stmt/doc-baseline.json new file mode 100644 index 000000000..7dff5069b --- /dev/null +++ b/testsuite/tests/unparsing/named_stmt/doc-baseline.json @@ -0,0 +1,149 @@ +{ + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo:" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "loop" + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 6, + "kind": "text", + "text": "null;" + }, + { + "id": 9, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 10, + "kind": "text", + "text": "null;" + } + ] + } + } + }, + { + "id": 15, + "kind": "list", + "list": [ + { + "id": 13, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 16, + "kind": "text", + "text": "end loop;" + } + ] + }, + "break": true, + "expandedStates": null + } + } + ] + }, + "break": true, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/named_stmt/input.ada b/testsuite/tests/unparsing/named_stmt/input.ada new file mode 100644 index 000000000..74baccdfc --- /dev/null +++ b/testsuite/tests/unparsing/named_stmt/input.ada @@ -0,0 +1,5 @@ +Foo: +loop + null; + null; +end loop; diff --git a/testsuite/tests/unparsing/named_stmt/test.out b/testsuite/tests/unparsing/named_stmt/test.out new file mode 100644 index 000000000..74baccdfc --- /dev/null +++ b/testsuite/tests/unparsing/named_stmt/test.out @@ -0,0 +1,5 @@ +Foo: +loop + null; + null; +end loop; diff --git a/testsuite/tests/unparsing/named_stmt/test.yaml b/testsuite/tests/unparsing/named_stmt/test.yaml new file mode 100644 index 000000000..a8fc338f8 --- /dev/null +++ b/testsuite/tests/unparsing/named_stmt/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: stmt +description: | + Test that there is a hard line break between `f_decl` and `f_stmt`. Test that + `f_decl` and `f_stmt` both have the same indentation.