Skip to content

Commit

Permalink
REGEX FRONTEND: allow equals sign in member routine definition prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
awnawab committed Nov 16, 2023
1 parent a851213 commit fc0d872
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions loki/frontend/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ def __init__(self):
r'^(?P<prefix>[ \t\w()=]*)?(?P<keyword>subroutine|function)[ \t]+(?P<name>\w+)\b.*?$'
r'(?P<spec>(?:.*?(?:^(?:abstract[ \t]+)?interface\b.*?^end[ \t]+interface)?)+)'
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]*(?P=keyword)\b(?:[ \t](?P=name))?',
Expand Down
14 changes: 8 additions & 6 deletions tests/test_frontends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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'])
Expand Down

0 comments on commit fc0d872

Please sign in to comment.