diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 5f25140fa..5edf4c471 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -537,6 +537,40 @@ "must_break": false } }, + "BeginBlock": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "begin" + }, + { + "kind": "recurse_field", + "field": "f_stmts" + }, + "hardline", + { + "kind": "text", + "text": "end" + }, + { + "kind": "recurse_field", + "field": "f_end_name" + }, + { + "kind": "text", + "text": ";" + } + ] + }, + "fields": { + "f_end_name": [ + "whitespace", + "recurse" + ] + } + }, "BinOp": { "node": { "kind": "group", diff --git a/testsuite/tests/unparsing/begin_block/with_f_exceptions/input.ada b/testsuite/tests/unparsing/begin_block/with_f_exceptions/input.ada new file mode 100644 index 000000000..ef9f301aa --- /dev/null +++ b/testsuite/tests/unparsing/begin_block/with_f_exceptions/input.ada @@ -0,0 +1 @@ +begin null; exception when others => null; end; diff --git a/testsuite/tests/unparsing/begin_block/with_f_exceptions/test.out b/testsuite/tests/unparsing/begin_block/with_f_exceptions/test.out new file mode 100644 index 000000000..30bae1687 --- /dev/null +++ b/testsuite/tests/unparsing/begin_block/with_f_exceptions/test.out @@ -0,0 +1,6 @@ +begin + null; +exception + when others => + null; +end; diff --git a/testsuite/tests/unparsing/begin_block/with_f_exceptions/test.yaml b/testsuite/tests/unparsing/begin_block/with_f_exceptions/test.yaml new file mode 100644 index 000000000..e09371b76 --- /dev/null +++ b/testsuite/tests/unparsing/begin_block/with_f_exceptions/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: stmt +description: | + Test that the `begin`, `expection` and `end` keywords are aligned. + Also test that `f_stmts.f_stmts` and `f_stmts.f_exceptions` are aligned. diff --git a/testsuite/tests/unparsing/begin_block/without_f_exceptions/input.ada b/testsuite/tests/unparsing/begin_block/without_f_exceptions/input.ada new file mode 100644 index 000000000..dc761bff1 --- /dev/null +++ b/testsuite/tests/unparsing/begin_block/without_f_exceptions/input.ada @@ -0,0 +1 @@ +begin null; end; diff --git a/testsuite/tests/unparsing/begin_block/without_f_exceptions/test.out b/testsuite/tests/unparsing/begin_block/without_f_exceptions/test.out new file mode 100644 index 000000000..1b2546d57 --- /dev/null +++ b/testsuite/tests/unparsing/begin_block/without_f_exceptions/test.out @@ -0,0 +1,3 @@ +begin + null; +end; diff --git a/testsuite/tests/unparsing/begin_block/without_f_exceptions/test.yaml b/testsuite/tests/unparsing/begin_block/without_f_exceptions/test.yaml new file mode 100644 index 000000000..e8012fdff --- /dev/null +++ b/testsuite/tests/unparsing/begin_block/without_f_exceptions/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: stmt +description: | + Test that the `begin` and `end` keywords are aligned and `f_stmts.f_stmts` is + indented.