From 359e5a29c7c2a676e3343faea4673423d12d082e Mon Sep 17 00:00:00 2001 From: dbroemmel Date: Mon, 3 Jul 2023 16:13:40 +0200 Subject: [PATCH 01/10] allow named select case --- fortran_tests/after/example.f90 | 6 +++--- fortran_tests/before/example.f90 | 6 +++--- fortran_tests/test_results/expected_results | 2 +- fprettify/__init__.py | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fortran_tests/after/example.f90 b/fortran_tests/after/example.f90 index ed6c30b..05c4513 100644 --- a/fortran_tests/after/example.f90 +++ b/fortran_tests/after/example.f90 @@ -194,8 +194,8 @@ program example_prog ! example 4.1 l = 0 do r = 1, 10 - select case (r) - case (1) + case_label: select case(r) + case (1) case_label do i = 1, 100; if (i <= 2) then! comment do j = 1, 5 do k = 1, 3 @@ -211,7 +211,7 @@ program example_prog end do case (2) l = i + j + k - end select + end select case_label end do ! example 4.2 diff --git a/fortran_tests/before/example.f90 b/fortran_tests/before/example.f90 index d6b3ecb..aee6eb3 100644 --- a/fortran_tests/before/example.f90 +++ b/fortran_tests/before/example.f90 @@ -195,8 +195,8 @@ program example_prog ! example 4.1 l = 0 do r = 1, 10 - select case ( r ) - case( 1) + case_label : select case ( r ) + case( 1) case_label do i=1,100;if (i<=2) then! comment do j = 1,5 do k= 1, 3 @@ -212,7 +212,7 @@ program example_prog enddo case(2 ) l = i+ j + k - end select + end select case_label enddo ! example 4.2 diff --git a/fortran_tests/test_results/expected_results b/fortran_tests/test_results/expected_results index e109307..e74dbd4 100644 --- a/fortran_tests/test_results/expected_results +++ b/fortran_tests/test_results/expected_results @@ -1,4 +1,4 @@ -example.f90 : f5b449553856f8e62b253402ed2189044554f53c9954aad045db44ff3c2d49b7 +example.f90 : 1df5c1b38944d87eb73c561a9e13e4ea644ed5027c74367e3edbbf3903509dc4 RosettaCodeData/Task/100-doors/Fortran/100-doors-1.f : b44289edb55a75ca29407be3ca0d997119253d4c7adb5b3dfc1119944036ab0f RosettaCodeData/Task/100-doors/Fortran/100-doors-2.f : 263122b2af3e3637a7dab0bc0216dec27d76068b7352e9ab85e420de625408be RosettaCodeData/Task/24-game-Solve/Fortran/24-game-solve-1.f : 8927cfcfe15685f1513ed923b7ac38058358ec6586de83920679b537aa5b2d03 diff --git a/fprettify/__init__.py b/fprettify/__init__.py index d6450a3..f03232a 100644 --- a/fprettify/__init__.py +++ b/fprettify/__init__.py @@ -112,10 +112,10 @@ ENDDO_RE = re.compile(SOL_STR + r"END\s*DO(\s+\w+)?" + EOL_STR, RE_FLAGS) SELCASE_RE = re.compile( - SOL_STR + r"SELECT\s*(CASE|RANK|TYPE)\s*\(.*\)" + EOL_STR, RE_FLAGS) + SOL_STR + r"(\w+\s*:)?\s*SELECT\s*(CASE|RANK|TYPE)\s*\(.*\)" + EOL_STR, RE_FLAGS) CASE_RE = re.compile( - SOL_STR + r"((CASE|RANK|TYPE\s+IS|CLASS\s+IS)\s*(\(.*\)|DEFAULT)|CLASS\s+DEFAULT)" + EOL_STR, RE_FLAGS) -ENDSEL_RE = re.compile(SOL_STR + r"END\s*SELECT" + EOL_STR, RE_FLAGS) + SOL_STR + r"((CASE|RANK|TYPE\s+IS|CLASS\s+IS)\s*(\(.*\)|DEFAULT)|CLASS\s+DEFAULT)(\s+\w+)?" + EOL_STR, RE_FLAGS) +ENDSEL_RE = re.compile(SOL_STR + r"END\s*SELECT(\s+\w+)?" + EOL_STR, RE_FLAGS) ASSOCIATE_RE = re.compile(SOL_STR + r"ASSOCIATE\s*\(.*\)" + EOL_STR, RE_FLAGS) ENDASSOCIATE_RE = re.compile(SOL_STR + r"END\s*ASSOCIATE" + EOL_STR, RE_FLAGS) @@ -1308,7 +1308,7 @@ def add_whitespace_context(line, spacey): line = ''.join(line_parts) - for newre in [IF_RE, DO_RE, BLK_RE]: + for newre in [IF_RE, DO_RE, BLK_RE, SELCASE_RE]: if newre.search(line) and re.search(SOL_STR + r"\w+\s*:", line): line = ': '.join(_.strip() for _ in line.split(':', 1)) From b0ec7649cd57f80d7ce94c709294bf88da86f068 Mon Sep 17 00:00:00 2001 From: dbroemmel Date: Mon, 3 Jul 2023 16:38:21 +0200 Subject: [PATCH 02/10] fixing named case --- fortran_tests/after/example.f90 | 2 +- fortran_tests/test_results/expected_results | 2 +- fprettify/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fortran_tests/after/example.f90 b/fortran_tests/after/example.f90 index 05c4513..9b3ea4c 100644 --- a/fortran_tests/after/example.f90 +++ b/fortran_tests/after/example.f90 @@ -194,7 +194,7 @@ program example_prog ! example 4.1 l = 0 do r = 1, 10 - case_label: select case(r) + case_label: select case (r) case (1) case_label do i = 1, 100; if (i <= 2) then! comment do j = 1, 5 diff --git a/fortran_tests/test_results/expected_results b/fortran_tests/test_results/expected_results index e74dbd4..504bbf8 100644 --- a/fortran_tests/test_results/expected_results +++ b/fortran_tests/test_results/expected_results @@ -1,4 +1,4 @@ -example.f90 : 1df5c1b38944d87eb73c561a9e13e4ea644ed5027c74367e3edbbf3903509dc4 +example.f90 : e2554d901dea8f89bab644c02750ab2120e358680fb81b07188010a5d1f47fbd RosettaCodeData/Task/100-doors/Fortran/100-doors-1.f : b44289edb55a75ca29407be3ca0d997119253d4c7adb5b3dfc1119944036ab0f RosettaCodeData/Task/100-doors/Fortran/100-doors-2.f : 263122b2af3e3637a7dab0bc0216dec27d76068b7352e9ab85e420de625408be RosettaCodeData/Task/24-game-Solve/Fortran/24-game-solve-1.f : 8927cfcfe15685f1513ed923b7ac38058358ec6586de83920679b537aa5b2d03 diff --git a/fprettify/__init__.py b/fprettify/__init__.py index f03232a..1697298 100644 --- a/fprettify/__init__.py +++ b/fprettify/__init__.py @@ -1154,7 +1154,7 @@ def add_whitespace_charwise(line, spacey, scope_parser, format_decl, filename, l line[:pos], RE_FLAGS) or re.search(SOL_STR + r"(\w+\s*:)?\s*DO\s+WHILE\s*$", line[:pos], RE_FLAGS) or - re.search(SOL_STR + r"(SELECT)?\s*CASE\s*$", + re.search(SOL_STR + r"(\w+\s*:)?\s*(SELECT)?\s*CASE\s*$", line[:pos], RE_FLAGS) or re.search(SOL_STR + r"(SELECT)?\s*RANK\s*$", line[:pos], RE_FLAGS) or From b5e9a34846f4ed20a10d4c339c6d0179a996e49d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 13:38:03 +0000 Subject: [PATCH 03/10] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8c8214b..f7f9e5c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 212432e..22e3e9a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Create resource cache id: cache @@ -43,7 +43,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Load resources uses: actions/cache@v3 From 92a88164becb3bf409fffb443b64630b112474ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 13:40:50 +0000 Subject: [PATCH 04/10] Bump actions/setup-python from 4 to 5 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f7f9e5c..90cfe2c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.x" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 22e3e9a..028d80e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,7 +51,7 @@ jobs: path: ./fortran_tests/before/*/ key: resources-${{ github.event_name }} - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.x" From 6bd78d9fc1a0c6bc75899885a2bd4f89e85ea7ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 13:17:43 +0000 Subject: [PATCH 05/10] Bump actions/cache from 3 to 4 Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 028d80e..c41da81 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: - name: Create resource cache id: cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ./fortran_tests/before/*/ key: resources-${{ github.event_name }} @@ -46,7 +46,7 @@ jobs: uses: actions/checkout@v4 - name: Load resources - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ./fortran_tests/before/*/ key: resources-${{ github.event_name }} From 92f5b9c70c00f51b57b5a4fb0d464c51e22237bb Mon Sep 17 00:00:00 2001 From: dbroemmel Date: Thu, 23 Jan 2025 16:23:49 +0100 Subject: [PATCH 06/10] Attempt to fix pipeline fail --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c41da81..f11ce53 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"] + python: ["3.8", "3.9", "3.10", "3.11". "3.12", "3.13"] steps: - name: Checkout code From 0289b2ab41c0e6f6dea992e52496c5d8a3a546fa Mon Sep 17 00:00:00 2001 From: dbroemmel Date: Thu, 23 Jan 2025 16:26:15 +0100 Subject: [PATCH 07/10] . --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f11ce53..f733974 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python: ["3.8", "3.9", "3.10", "3.11". "3.12", "3.13"] + python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout code From 22d1fc1de38b1e8e46c1cae1f8dacafc2996545b Mon Sep 17 00:00:00 2001 From: dbroemmel Date: Fri, 24 Jan 2025 09:23:57 +0100 Subject: [PATCH 08/10] Removing newer Python versions The latest Python versions require an updated test system. This may be found from #140 or in the matching branch. Not looking into this right now, instead simply removing newer Python versions from action. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f733974..e40ed20 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + python: ["3.8", "3.9", "3.10", "3.11"] steps: - name: Checkout code From 0e32479572ce81dc16b4e378367fe68244066d0c Mon Sep 17 00:00:00 2001 From: dbroemmel Date: Mon, 3 Jul 2023 16:13:40 +0200 Subject: [PATCH 09/10] allow named select case --- fortran_tests/after/example.f90 | 6 +++--- fortran_tests/before/example.f90 | 6 +++--- fortran_tests/test_results/expected_results | 2 +- fprettify/__init__.py | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fortran_tests/after/example.f90 b/fortran_tests/after/example.f90 index ed6c30b..05c4513 100644 --- a/fortran_tests/after/example.f90 +++ b/fortran_tests/after/example.f90 @@ -194,8 +194,8 @@ program example_prog ! example 4.1 l = 0 do r = 1, 10 - select case (r) - case (1) + case_label: select case(r) + case (1) case_label do i = 1, 100; if (i <= 2) then! comment do j = 1, 5 do k = 1, 3 @@ -211,7 +211,7 @@ program example_prog end do case (2) l = i + j + k - end select + end select case_label end do ! example 4.2 diff --git a/fortran_tests/before/example.f90 b/fortran_tests/before/example.f90 index d6b3ecb..aee6eb3 100644 --- a/fortran_tests/before/example.f90 +++ b/fortran_tests/before/example.f90 @@ -195,8 +195,8 @@ program example_prog ! example 4.1 l = 0 do r = 1, 10 - select case ( r ) - case( 1) + case_label : select case ( r ) + case( 1) case_label do i=1,100;if (i<=2) then! comment do j = 1,5 do k= 1, 3 @@ -212,7 +212,7 @@ program example_prog enddo case(2 ) l = i+ j + k - end select + end select case_label enddo ! example 4.2 diff --git a/fortran_tests/test_results/expected_results b/fortran_tests/test_results/expected_results index e109307..e74dbd4 100644 --- a/fortran_tests/test_results/expected_results +++ b/fortran_tests/test_results/expected_results @@ -1,4 +1,4 @@ -example.f90 : f5b449553856f8e62b253402ed2189044554f53c9954aad045db44ff3c2d49b7 +example.f90 : 1df5c1b38944d87eb73c561a9e13e4ea644ed5027c74367e3edbbf3903509dc4 RosettaCodeData/Task/100-doors/Fortran/100-doors-1.f : b44289edb55a75ca29407be3ca0d997119253d4c7adb5b3dfc1119944036ab0f RosettaCodeData/Task/100-doors/Fortran/100-doors-2.f : 263122b2af3e3637a7dab0bc0216dec27d76068b7352e9ab85e420de625408be RosettaCodeData/Task/24-game-Solve/Fortran/24-game-solve-1.f : 8927cfcfe15685f1513ed923b7ac38058358ec6586de83920679b537aa5b2d03 diff --git a/fprettify/__init__.py b/fprettify/__init__.py index d6450a3..f03232a 100644 --- a/fprettify/__init__.py +++ b/fprettify/__init__.py @@ -112,10 +112,10 @@ ENDDO_RE = re.compile(SOL_STR + r"END\s*DO(\s+\w+)?" + EOL_STR, RE_FLAGS) SELCASE_RE = re.compile( - SOL_STR + r"SELECT\s*(CASE|RANK|TYPE)\s*\(.*\)" + EOL_STR, RE_FLAGS) + SOL_STR + r"(\w+\s*:)?\s*SELECT\s*(CASE|RANK|TYPE)\s*\(.*\)" + EOL_STR, RE_FLAGS) CASE_RE = re.compile( - SOL_STR + r"((CASE|RANK|TYPE\s+IS|CLASS\s+IS)\s*(\(.*\)|DEFAULT)|CLASS\s+DEFAULT)" + EOL_STR, RE_FLAGS) -ENDSEL_RE = re.compile(SOL_STR + r"END\s*SELECT" + EOL_STR, RE_FLAGS) + SOL_STR + r"((CASE|RANK|TYPE\s+IS|CLASS\s+IS)\s*(\(.*\)|DEFAULT)|CLASS\s+DEFAULT)(\s+\w+)?" + EOL_STR, RE_FLAGS) +ENDSEL_RE = re.compile(SOL_STR + r"END\s*SELECT(\s+\w+)?" + EOL_STR, RE_FLAGS) ASSOCIATE_RE = re.compile(SOL_STR + r"ASSOCIATE\s*\(.*\)" + EOL_STR, RE_FLAGS) ENDASSOCIATE_RE = re.compile(SOL_STR + r"END\s*ASSOCIATE" + EOL_STR, RE_FLAGS) @@ -1308,7 +1308,7 @@ def add_whitespace_context(line, spacey): line = ''.join(line_parts) - for newre in [IF_RE, DO_RE, BLK_RE]: + for newre in [IF_RE, DO_RE, BLK_RE, SELCASE_RE]: if newre.search(line) and re.search(SOL_STR + r"\w+\s*:", line): line = ': '.join(_.strip() for _ in line.split(':', 1)) From 2c0664414431d5ccf0ae8070ae89418f0a4673e6 Mon Sep 17 00:00:00 2001 From: dbroemmel Date: Mon, 3 Jul 2023 16:38:21 +0200 Subject: [PATCH 10/10] fixing named case --- fortran_tests/after/example.f90 | 2 +- fortran_tests/test_results/expected_results | 2 +- fprettify/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fortran_tests/after/example.f90 b/fortran_tests/after/example.f90 index 05c4513..9b3ea4c 100644 --- a/fortran_tests/after/example.f90 +++ b/fortran_tests/after/example.f90 @@ -194,7 +194,7 @@ program example_prog ! example 4.1 l = 0 do r = 1, 10 - case_label: select case(r) + case_label: select case (r) case (1) case_label do i = 1, 100; if (i <= 2) then! comment do j = 1, 5 diff --git a/fortran_tests/test_results/expected_results b/fortran_tests/test_results/expected_results index e74dbd4..504bbf8 100644 --- a/fortran_tests/test_results/expected_results +++ b/fortran_tests/test_results/expected_results @@ -1,4 +1,4 @@ -example.f90 : 1df5c1b38944d87eb73c561a9e13e4ea644ed5027c74367e3edbbf3903509dc4 +example.f90 : e2554d901dea8f89bab644c02750ab2120e358680fb81b07188010a5d1f47fbd RosettaCodeData/Task/100-doors/Fortran/100-doors-1.f : b44289edb55a75ca29407be3ca0d997119253d4c7adb5b3dfc1119944036ab0f RosettaCodeData/Task/100-doors/Fortran/100-doors-2.f : 263122b2af3e3637a7dab0bc0216dec27d76068b7352e9ab85e420de625408be RosettaCodeData/Task/24-game-Solve/Fortran/24-game-solve-1.f : 8927cfcfe15685f1513ed923b7ac38058358ec6586de83920679b537aa5b2d03 diff --git a/fprettify/__init__.py b/fprettify/__init__.py index f03232a..1697298 100644 --- a/fprettify/__init__.py +++ b/fprettify/__init__.py @@ -1154,7 +1154,7 @@ def add_whitespace_charwise(line, spacey, scope_parser, format_decl, filename, l line[:pos], RE_FLAGS) or re.search(SOL_STR + r"(\w+\s*:)?\s*DO\s+WHILE\s*$", line[:pos], RE_FLAGS) or - re.search(SOL_STR + r"(SELECT)?\s*CASE\s*$", + re.search(SOL_STR + r"(\w+\s*:)?\s*(SELECT)?\s*CASE\s*$", line[:pos], RE_FLAGS) or re.search(SOL_STR + r"(SELECT)?\s*RANK\s*$", line[:pos], RE_FLAGS) or