Skip to content

Commit

Permalink
Merge pull request #657 from Fortran-FOSS-Programmers/fix-whitespace-…
Browse files Browse the repository at this point in the history
…issues

Fix issue with no whitespace between type and `function`
  • Loading branch information
ZedThree authored Jul 29, 2024
2 parents e6aa113 + 55c9713 commit ac5ed02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ford/sourceform.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ class FortranContainer(FortranBase):
re.IGNORECASE | re.VERBOSE,
)
FUNCTION_RE = re.compile(
r"""^(?:(?P<attributes>.+?)\s+)? # Optional attributes (including type)
r"""^(?:(?P<attributes>.+?)\s*)? # Optional attributes (including type)
function\s+(?P<name>\w+)\s* # Required function name
(?P<arguments>\([^()]*\))? # Required arguments
(?=(?:.*result\s*\(\s*(?P<result>\w+)\s*\))?) # Optional result name
Expand Down
12 changes: 12 additions & 0 deletions test/test_sourceform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2256,3 +2256,15 @@ def test_blocks_with_type(parse_fortran_file):
source = parse_fortran_file(data)
module = source.modules[0]
assert len(module.subroutines) == 1


def test_no_space_after_character_type(parse_fortran_file):
data = """\
CHARACTER(LEN=250)FUNCTION FirstWord( sString ) RESULT( sRes )
CHARACTER(LEN=250)sString
END FUNCTION FirstWord
"""

source = parse_fortran_file(data)
function = source.functions[0]
assert function.name.lower() == "firstword"

0 comments on commit ac5ed02

Please sign in to comment.