summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-08-21 01:06:51 (GMT)
committerSteven Knight <knight@baldmt.com>2005-08-21 01:06:51 (GMT)
commit93e408515a55593b0c27f39220e4aa37131d1f0d (patch)
tree84159b19bcf3c181e22e142162b06487f2a2f61b /src/engine
parentc5f5ba58f1c8b4927ee22e3781a19c334352aa45 (diff)
downloadSCons-93e408515a55593b0c27f39220e4aa37131d1f0d.zip
SCons-93e408515a55593b0c27f39220e4aa37131d1f0d.tar.gz
SCons-93e408515a55593b0c27f39220e4aa37131d1f0d.tar.bz2
Handle Fortran MODULE definitions in the same file. (Craig Scott)
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Scanner/Fortran.py43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py
index 66bec0c..8f7a6ce 100644
--- a/src/engine/SCons/Scanner/Fortran.py
+++ b/src/engine/SCons/Scanner/Fortran.py
@@ -54,11 +54,12 @@ class F90Scanner(SCons.Scanner.Classic):
smart thing to do.
"""
- def __init__(self, name, suffixes, path_variable, use_regex,
- incl_regex, *args, **kw):
+ def __init__(self, name, suffixes, path_variable,
+ use_regex, incl_regex, def_regex, *args, **kw):
self.cre_use = re.compile(use_regex, re.M)
self.cre_incl = re.compile(incl_regex, re.M)
+ self.cre_def = re.compile(def_regex, re.M)
def _scan(node, env, path, self=self):
node = node.rfile()
@@ -78,7 +79,7 @@ class F90Scanner(SCons.Scanner.Classic):
def scan(self, node, env, path=()):
"__cacheable__"
-
+
# cache the includes list in node so we only scan it once:
if node.includes != None:
mods_and_includes = node.includes
@@ -87,6 +88,15 @@ class F90Scanner(SCons.Scanner.Classic):
includes = self.cre_incl.findall(node.get_contents())
# retrieve all USE'd module names
modules = self.cre_use.findall(node.get_contents())
+ # retrieve all defined module names
+ defmodules = self.cre_def.findall(node.get_contents())
+
+ # Remove all USE'd module names that are defined in the same file
+ d = {}
+ for m in defmodules:
+ d[m] = 1
+ modules = filter(lambda m, d=d: not d.has_key(m), modules)
+ #modules = self.undefinedModules(modules, defmodules)
# Convert module name to a .mod filename
suffix = env.subst('$FORTRANMODSUFFIX')
@@ -270,9 +280,34 @@ def FortranScan(path_variable="FORTRANPATH"):
include_regex = """(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])"""
+# The MODULE statement regex finds module definitions by matching
+# the following:
+#
+# MODULE module_name
+#
+# but *not* the following:
+#
+# MODULE PROCEDURE procedure_name
+#
+# Here is a breakdown of the regex:
+#
+# (?i) : regex is case insensitive
+# ^\s* : any amount of white space
+# MODULE : match the string MODULE, case insensitive
+# \s+ : match one or more white space characters
+# (?!PROCEDURE) : but *don't* match if the next word matches
+# PROCEDURE (negative lookahead assertion),
+# case insensitive
+# (\w+) : match one or more alphanumeric characters
+# that make up the defined module name and
+# save it in a group
+
+ def_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"""
+
scanner = F90Scanner("FortranScan",
"$FORTRANSUFFIXES",
path_variable,
use_regex,
- include_regex)
+ include_regex,
+ def_regex)
return scanner