Support for Fortran 2008 submodules.

This commit is contained in:
Harald Klimach 2018-12-21 19:53:12 +01:00
parent 3d1744151f
commit e77a6561a1
2 changed files with 25 additions and 5 deletions

View File

@ -28,10 +28,24 @@ def modfile(conf, name):
Turns a module name into the right module file name.
Defaults to all lower case.
"""
return {'lower' :name.lower() + '.mod',
'lower.MOD' :name.lower() + '.MOD',
'UPPER.mod' :name.upper() + '.mod',
'UPPER' :name.upper() + '.MOD'}[conf.env.FC_MOD_CAPITALIZATION or 'lower']
if name.find(':') >= 0:
# Depending on a submodule!
separator = conf.env.FC_SUBMOD_SEPARATOR or '@'
# Ancestors of the submodule will be prefixed to the
# submodule name, separated by a colon.
modpath = name.split(':')
# Only the ancestor (actual) module and the submodule name
# will be used for the filename.
modname = modpath[0] + separator + modpath[-1]
suffix = conf.env.FC_SUBMOD_SUFFIX or '.smod'
else:
modname = name
suffix = '.mod'
return {'lower' :modname.lower() + suffix.lower(),
'lower.MOD' :modname.lower() + suffix.upper(),
'UPPER.mod' :modname.upper() + suffix.lower(),
'UPPER' :modname.upper() + suffix.upper()}[conf.env.FC_MOD_CAPITALIZATION or 'lower']
def get_fortran_tasks(tsk):
"""

View File

@ -7,11 +7,13 @@ import re
INC_REGEX = """(?:^|['">]\s*;)\s*(?:|#\s*)INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])"""
USE_REGEX = """(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)"""
MOD_REGEX = """(?:^|;)\s*MODULE(?!\s*PROCEDURE)(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)"""
MOD_REGEX = """(?:^|;)\s*MODULE(?!\s+(?:PROCEDURE|SUBROUTINE|FUNCTION))\s+(\w+)"""
SMD_REGEX = """(?:^|;)\s*SUBMODULE\s*\(([\w:]+)\)\s*(\w+)"""
re_inc = re.compile(INC_REGEX, re.I)
re_use = re.compile(USE_REGEX, re.I)
re_mod = re.compile(MOD_REGEX, re.I)
re_smd = re.compile(SMD_REGEX, re.I)
class fortran_parser(object):
"""
@ -58,6 +60,10 @@ class fortran_parser(object):
m = re_mod.search(line)
if m:
mods.append(m.group(1))
m = re_smd.search(line)
if m:
uses.append(m.group(1))
mods.append('{0}:{1}'.format(m.group(1),m.group(2))
return (incs, uses, mods)
def start(self, node):