Skip to content

Commit

Permalink
Fix ModulePattern for functions with kind in their return type
Browse files Browse the repository at this point in the history
  • Loading branch information
reuterbal committed Mar 27, 2024
1 parent c6bcc64 commit 634e516
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions loki/frontend/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ def __init__(self):
r'^module[ \t]+(?P<name>\w+)\b.*?$'
r'(?P<spec>.*?)'
r'(?P<contains>^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]*module\b(?:[ \t](?P=name))?',
Expand Down
7 changes: 4 additions & 3 deletions tests/test_frontends.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,9 @@ def test_regex_module_from_source():
"""
fcode = """
module some_module
implicit none
use foobar
implicit none
integer, parameter :: k = selected_int_kind(5)
contains
subroutine module_routine
integer m
Expand All @@ -481,9 +482,9 @@ def test_regex_module_from_source():
call routine_b(m, 6)
end subroutine module_routine
function module_function(n)
integer(kind=k) function module_function(n)
integer n
n = 3
module_function = n + 2
end function module_function
end module some_module
""".strip()
Expand Down

0 comments on commit 634e516

Please sign in to comment.