From 8c3313c404b0872457ecdd011b940538bdbf50ab Mon Sep 17 00:00:00 2001 From: Joao Azevedo Date: Tue, 30 Jul 2024 08:47:30 +0000 Subject: [PATCH] Add config for BeginBlock --- extensions/default_unparsing_config.json | 34 +++++++++++++++++++ .../begin_block/with_f_exceptions/input.ada | 1 + .../begin_block/with_f_exceptions/test.out | 6 ++++ .../begin_block/with_f_exceptions/test.yaml | 5 +++ .../without_f_exceptions/input.ada | 1 + .../begin_block/without_f_exceptions/test.out | 3 ++ .../without_f_exceptions/test.yaml | 5 +++ 7 files changed, 55 insertions(+) create mode 100644 testsuite/tests/unparsing/begin_block/with_f_exceptions/input.ada create mode 100644 testsuite/tests/unparsing/begin_block/with_f_exceptions/test.out create mode 100644 testsuite/tests/unparsing/begin_block/with_f_exceptions/test.yaml create mode 100644 testsuite/tests/unparsing/begin_block/without_f_exceptions/input.ada create mode 100644 testsuite/tests/unparsing/begin_block/without_f_exceptions/test.out create mode 100644 testsuite/tests/unparsing/begin_block/without_f_exceptions/test.yaml 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.