From 5a177b509417072b336f7e27daa33b40932d57d0 Mon Sep 17 00:00:00 2001 From: Ahmad Nawab Date: Wed, 15 Nov 2023 16:49:20 +0000 Subject: [PATCH] REGEX FRONTEND: allow equals sign in member routine definition prefix --- loki/frontend/regex.py | 4 ++-- tests/test_frontends.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/loki/frontend/regex.py b/loki/frontend/regex.py index 888cbaa8e..bd3fa79fc 100644 --- a/loki/frontend/regex.py +++ b/loki/frontend/regex.py @@ -468,8 +468,8 @@ def __init__(self): r'^(?P[ \t\w()=]*)?(?Psubroutine|function)[ \t]+(?P\w+)\b.*?$' r'(?P(?:.*?(?:^(?:abstract[ \t]+)?interface\b.*?^end[ \t]+interface)?)+)' r'(?P^contains\n(?:' - r'(?:[ \t\w()]*?subroutine.*?^end[ \t]*subroutine\b(?:[ \t]\w+)?\n)|' - r'(?:[ \t\w()]*?function.*?^end[ \t]*function\b(?:[ \t]\w+)?\n)|' + r'(?:[ \t\w()=]*?subroutine.*?^end[ \t]*subroutine\b(?:[ \t]\w+)?\n)|' + r'(?:[ \t\w()=]*?function.*?^end[ \t]*function\b(?:[ \t]\w+)?\n)|' r'(?:^#\w+.*?\n)' r')*)?' r'^end[ \t]*(?P=keyword)\b(?:[ \t](?P=name))?', diff --git a/tests/test_frontends.py b/tests/test_frontends.py index ff6ce9d59..353ecb4bf 100644 --- a/tests/test_frontends.py +++ b/tests/test_frontends.py @@ -381,6 +381,7 @@ def test_regex_subroutine_from_source(): ! arg2 j ) + use parkind1, only : jpim implicit none integer, intent(in) :: i, j integer b @@ -391,16 +392,17 @@ def test_regex_subroutine_from_source(): call routine_a() contains !abc ^$^** + integer(kind=jpim) function contained_e(i) + integer, intent(in) :: i + contained_e = i + end function + subroutine contained_c(i) integer, intent(in) :: i integer c c = 5 end subroutine contained_c ! cc£$^£$^ - integer function contained_e(i) - integer, intent(in) :: i - contained_e = i - end function subroutine contained_d(i) integer, intent(in) :: i @@ -415,7 +417,7 @@ def test_regex_subroutine_from_source(): assert not routine.is_function assert routine.arguments == () assert routine.argnames == [] - assert [r.name for r in routine.subroutines] == ['contained_c', 'contained_e', 'contained_d'] + assert [r.name for r in routine.subroutines] == ['contained_e', 'contained_c', 'contained_d'] contained_c = routine['contained_c'] assert contained_c.name == 'contained_c' @@ -1487,7 +1489,7 @@ def test_regex_fypp(): @pytest.mark.parametrize( - 'frontend', + 'frontend', available_frontends(include_regex=True, xfail=[(OMNI, 'OMNI may segfault on empty files')]) ) @pytest.mark.parametrize('fcode', ['', '\n', '\n\n\n\n'])