Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tclune authored Jul 10, 2024
2 parents 3ef8192 + decc27e commit 39990ca
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 53 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Removes numerous SyntaxWarning messages during compilation and parsing when working with python >= 3.12 by using raw strings to hold all regular expressions.
- This fixes a small CMake bug which can lead to posix_predefined.x being built in the wrong build subdirectory when CMAKE_RUNTIME_OUTPUT_DIRECTORY is set*.
- Missing implementation of `assertIsFinite_real80()`. Apparently undetected until recent attempt to port to flang.
- Made support for REAL128 optional. (Port to nvfortran)
Expand Down
84 changes: 42 additions & 42 deletions bin/funit/pFUnitParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def cppSetLineAndFile(line, file):

def getSubroutineName(line):
try:
m = re.match('\s*subroutine\s+(\w*)\s*(\\([\w\s,]*\\))?\s*(!.*)*$', line, re.IGNORECASE)
m = re.match(r'\s*subroutine\s+(\w*)\s*(\([\w\s,]*\))?\s*(!.*)*$', line, re.IGNORECASE)
return m.groups()[0]
except:
raise MyError('Improper format in declaration of test procedure.')
Expand All @@ -43,7 +43,7 @@ def parseArgsFirstRest(directiveName,line):

argStr = '';
if directiveName != '':
m = re.match('\s*'+directiveName+'\s*\\((.*\w.*)\\)\s*$',line,re.IGNORECASE)
m = re.match(r'\s*'+directiveName+r'\s*\((.*\w.*)\)\s*$',line,re.IGNORECASE)
if m:
argStr = m.groups()[0]
else:
Expand Down Expand Up @@ -85,14 +85,14 @@ def parseArgsFirstSecondRest(directiveName,line):


def getSelfObjectName(line):
m = re.match('\s*subroutine\s+\w*\s*\\(\s*(\w+)\s*(,\s*\w+\s*)*\\)\s*$', line, re.IGNORECASE)
m = re.match(r'\s*subroutine\s+\w*\s*\(\s*(\w+)\s*(,\s*\w+\s*)*\)\s*$', line, re.IGNORECASE)
if m:
return m.groups()[0]
else:
return m

def getTypeName(line):
m = re.match('\s*type(.*::\s*|\s+)(\w*)\s*$', line, re.IGNORECASE)
m = re.match(r'\s*type(.*::\s*|\s+)(\w*)\s*$', line, re.IGNORECASE)
return m.groups()[1]

class Action():
Expand All @@ -112,7 +112,7 @@ def __init__(self, parser):

def match(self, line):
if (self.parser.looking_for_test_name):
m = re.match('\s*subroutine\s+(\w*)\s*(\\([\w\s,]*\\))?\s*(!.*)*$', line, re.IGNORECASE)
m = re.match(r'\s*subroutine\s+(\w*)\s*(\([\w\s,]*\))?\s*(!.*)*$', line, re.IGNORECASE)
return m
else:
return False
Expand All @@ -135,43 +135,43 @@ def __init__(self, parser):
self.keyword = '@test'

def match(self, line):
m = re.match('\s*'+self.keyword+'(\s*(\\(.*\\))?\s*$)', line, re.IGNORECASE)
m = re.match(r'\s*'+self.keyword+r'(\s*(\(.*\))?\s*$)', line, re.IGNORECASE)
return m

def action(self, m, line):
options = re.match('\s*'+self.keyword+'\s*\\((.*)\\)\s*$', line, re.IGNORECASE)
options = re.match(r'\s*'+self.keyword+r'\s*\((.*)\)\s*$', line, re.IGNORECASE)
self.parser.current_method = {}

if options:

npesOption = re.search('npes\s*=\s*\\[([0-9,\s]+)\\]', options.groups()[0], re.IGNORECASE)
npesOption = re.search(r'npes\s*=\s*\[([0-9,\s]+)\]', options.groups()[0], re.IGNORECASE)
if npesOption:
npesString = npesOption.groups()[0]
npes = list(map(int, npesString.split(',')))
self.parser.current_method['npRequests'] = npes

#ifdef is optional
matchIfdef = re.match('.*ifdef\s*=\s*(\w+)', options.groups()[0], re.IGNORECASE)
matchIfdef = re.match(r'.*ifdef\s*=\s*(\w+)', options.groups()[0], re.IGNORECASE)
if matchIfdef:
ifdef = matchIfdef.groups()[0]
self.parser.current_method['ifdef'] = ifdef

matchIfndef = re.match('.*ifndef\s*=\s*(\w+)', options.groups()[0], re.IGNORECASE)
matchIfndef = re.match(r'.*ifndef\s*=\s*(\w+)', options.groups()[0], re.IGNORECASE)
if matchIfndef:
ifndef = matchIfndef.groups()[0]
self.parser.current_method['ifndef'] = ifndef

matchType = re.match('.*type\s*=\s*(\w+)', options.groups()[0], re.IGNORECASE)
matchType = re.match(r'.*type\s*=\s*(\w+)', options.groups()[0], re.IGNORECASE)
if matchType:
print ('Type', matchType.groups()[0])
self.parser.current_method['type'] = matchType.groups()[0]

paramOption = re.search('testParameters\s*=\s*[{](.*)[}]', options.groups()[0], re.IGNORECASE)
paramOption = re.search(r'testParameters\s*=\s*[{](.*)[}]', options.groups()[0], re.IGNORECASE)
if paramOption:
paramExpr = paramOption.groups()[0]
self.parser.current_method['testParameters'] = paramExpr

casesOption = re.search('cases\s*=\s*(\\[[0-9,\s]+\\])', options.groups()[0], re.IGNORECASE)
casesOption = re.search(r'cases\s*=\s*(\[[0-9,\s]+\])', options.groups()[0], re.IGNORECASE)
if casesOption:
self.parser.current_method['cases'] = casesOption.groups()[0]

Expand Down Expand Up @@ -206,28 +206,28 @@ def __init__(self, parser):
self.parser = parser

def match(self, line):
m = re.match('\s*@testcase\s*(|\\(.*\\))\s*$', line, re.IGNORECASE)
m = re.match(r'\s*@testcase\s*(|\(.*\))\s*$', line, re.IGNORECASE)
return m

def action(self, m, line):
options = re.match('\s*@testcase\s*\\((.*)\\)\s*$', line, re.IGNORECASE)
options = re.match(r'\s*@testcase\s*\((.*)\)\s*$', line, re.IGNORECASE)
if options:
value = re.search('constructor\s*=\s*(\w*)', options.groups()[0], re.IGNORECASE)
value = re.search(r'constructor\s*=\s*(\w*)', options.groups()[0], re.IGNORECASE)
if value:
self.parser.userTestCase['constructor'] = value.groups()[0]

value = re.search('npes\s*=\s*\\[([0-9,\s]+)\\]', options.groups()[0], re.IGNORECASE)
value = re.search(r'npes\s*=\s*\[([0-9,\s]+)\]', options.groups()[0], re.IGNORECASE)
if value:
npesString = value.groups()[0]
npes = list(map(int,npesString.split(',')))
self.parser.userTestCase['npRequests'] = npes

value = re.search('cases\s*=\s*(\\[[0-9,\s]+\\])', options.groups()[0], re.IGNORECASE)
value = re.search(r'cases\s*=\s*(\[[0-9,\s]+\])', options.groups()[0], re.IGNORECASE)
if value:
cases = value.groups()[0]
self.parser.userTestCase['cases'] = cases

value = re.search('testParameters\s*=\s*[{](.*)[}]', options.groups()[0], re.IGNORECASE)
value = re.search(r'testParameters\s*=\s*[{](.*)[}]', options.groups()[0], re.IGNORECASE)
if value:
paramExpr = value.groups()[0]
self.parser.userTestCase['testParameters'] = paramExpr
Expand All @@ -242,8 +242,8 @@ class AtSuite(Action):
def __init__(self, parser):
self.parser = parser
def match(self, line):
nameRe = "'\w+'|" + """\w+"""
m = re.match("\s*@suite\s*\\(\s*name\s*=\s*("+nameRe+")\s*\\)\s*$", line, re.IGNORECASE)
nameRe = r"'\w+'|" + r"""\w+"""
m = re.match(r"\s*@suite\s*\(\s*name\s*=\s*("+nameRe+r")\s*\)\s*$", line, re.IGNORECASE)
return m

def action(self, m, line):
Expand All @@ -256,7 +256,7 @@ def __init__(self, parser):
self.parser = parser

def match(self, line):
m = re.match('\s*module\s+(\w*)\s*$', line, re.IGNORECASE)
m = re.match(r'\s*module\s+(\w*)\s*$', line, re.IGNORECASE)
return m

def action(self, m, line):
Expand All @@ -279,7 +279,7 @@ def __init__(self, parser):

def match(self, line):
# m = re.match('\s*@assert('+assertVariants+')\s*\\((.*\w.*)\\)\s*$', line, re.IGNORECASE)
pattern = '\s*@assert(' + self.assert_variants + ')\s*\\((.*)\\)\s*$'
pattern = r'\s*@assert(' + self.assert_variants + r')\s*\((.*)\)\s*$'
match = re.match(pattern, line, re.IGNORECASE)

if match:
Expand Down Expand Up @@ -324,17 +324,17 @@ def __init__(self,parser):
self.parser = parser

def match(self, line):
m = re.match('\s*@assertassociated\s*\\((.*\w.*)\\)\s*$', line, re.IGNORECASE)
m = re.match(r'\s*@assertassociated\s*\((.*\w.*)\)\s*$', line, re.IGNORECASE)

if not m:
m = re.match( \
'\s*@assertassociated\s*\\((\s*([^,]*\w.*),\s*([^,]*\w.*),(.*\w*.*))\\)\s*$', \
r'\s*@assertassociated\s*\((\s*([^,]*\w.*),\s*([^,]*\w.*),(.*\w*.*))\)\s*$', \
line, re.IGNORECASE)

# How to get both (a,b) and (a,b,c) to match?
if not m:
m = re.match( \
'\s*@assertassociated\s*\\((\s*([^,]*\w.*),\s*([^,]*\w.*))\\)\s*$', \
r'\s*@assertassociated\s*\((\s*([^,]*\w.*),\s*([^,]*\w.*))\)\s*$', \
line, re.IGNORECASE)
return m

Expand Down Expand Up @@ -374,21 +374,21 @@ def __init__(self,parser):
self.name='@assertnotassociated'

def match(self, line):
m = re.match('\s*@assert(not|un)associated\s*\\((.*\w.*)\\)\s*$', line, re.IGNORECASE)
m = re.match(r'\s*@assert(not|un)associated\s*\((.*\w.*)\)\s*$', line, re.IGNORECASE)
if m:
self.name='@assert'+m.groups()[0]+'associated'
else:
self.name='@assertnotassociated'

if not m:
m = re.match( \
'\s*@assert(not|un)associated\s*\\((\s*([^,]*\w.*),\s*([^,]*\w.*),(.*\w*.*))\\)\s*$', \
r'\s*@assert(not|un)associated\s*\((\s*([^,]*\w.*),\s*([^,]*\w.*),(.*\w*.*))\)\s*$', \
line, re.IGNORECASE)

# How to get both (a,b) and (a,b,c) to match?
if not m:
m = re.match( \
'\s*@assert(not|un)associated\s*\\((\s*([^,]*\w.*),\s*([^,]*\w.*))\\)\s*$', \
r'\s*@assert(not|un)associated\s*\((\s*([^,]*\w.*),\s*([^,]*\w.*))\)\s*$', \
line, re.IGNORECASE)

if m:
Expand Down Expand Up @@ -439,13 +439,13 @@ def __init__(self,parser):

def match(self, line):
m = re.match( \
'\s*@assertequaluserdefined\s*\\((\s*([^,]*\w.*),\s*([^,]*\w.*),(.*\w*.*))\\)\s*$', \
r'\s*@assertequaluserdefined\s*\((\s*([^,]*\w.*),\s*([^,]*\w.*),(.*\w*.*))\)\s*$', \
line, re.IGNORECASE)

# How to get both (a,b) and (a,b,c) to match?
if not m:
m = re.match( \
'\s*@assertequaluserdefined\s*\\((\s*([^,]*\w.*),\s*([^,]*\w.*))\\)\s*$', \
r'\s*@assertequaluserdefined\s*\((\s*([^,]*\w.*),\s*([^,]*\w.*))\)\s*$', \
line, re.IGNORECASE)

return m
Expand Down Expand Up @@ -484,13 +484,13 @@ def __init__(self,parser):

def match(self, line):
m = re.match( \
'\s*@assertequivalent\s*\\((\s*([^,]*\w.*),\s*([^,]*\w.*),(.*\w*.*))\\)\s*$', \
r'\s*@assertequivalent\s*\((\s*([^,]*\w.*),\s*([^,]*\w.*),(.*\w*.*))\)\s*$', \
line, re.IGNORECASE)

# How to get both (a,b) and (a,b,c) to match?
if not m:
m = re.match( \
'\s*@assertequivalent\s*\\((\s*([^,]*\w.*),\s*([^,]*\w.*))\\)\s*$', \
r'\s*@assertequivalent\s*\((\s*([^,]*\w.*),\s*([^,]*\w.*))\)\s*$', \
line, re.IGNORECASE)

return m
Expand Down Expand Up @@ -526,7 +526,7 @@ def __init__(self, parser):
self.assert_variants = '|'.join(assert_operands.keys())

def match(self, line):
pattern = '\s*@mpiassert(' + self.assert_variants + ')\s*\\((.*\w.*)\\)\s*$'
pattern = r'\s*@mpiassert(' + self.assert_variants + r')\s*\((.*\w.*)\)\s*$'
match = re.match(pattern, line, re.IGNORECASE)

if match:
Expand Down Expand Up @@ -566,7 +566,7 @@ def __init__(self, parser):
self.parser = parser

def match(self, line):
m = re.match('\s*@before\s*$', line, re.IGNORECASE)
m = re.match(r'\s*@before\s*$', line, re.IGNORECASE)
return m

def action(self, m, line):
Expand All @@ -580,7 +580,7 @@ def __init__(self, parser):
self.parser = parser

def match(self, line):
m = re.match('\s*@after\s*$', line, re.IGNORECASE)
m = re.match(r'\s*@after\s*$', line, re.IGNORECASE)
return m

def action(self, m, line):
Expand All @@ -594,11 +594,11 @@ def __init__(self, parser):
self.parser = parser

def match(self, line):
m = re.match('\s*@testParameter\s*(|.*)$', line, re.IGNORECASE)
m = re.match(r'\s*@testParameter\s*(|.*)$', line, re.IGNORECASE)
return m

def action(self, m, line):
options = re.match('\s*@testParameter\s*\\((.*)\\)\s*$', line, re.IGNORECASE)
options = re.match(r'\s*@testParameter\s*\((.*)\)\s*$', line, re.IGNORECASE)

self.parser.commentLine(line)
nextLine = self.parser.nextLine()
Expand All @@ -607,7 +607,7 @@ def action(self, m, line):
self.parser.outputFile.write(nextLine)

if options:
value = re.search('constructor\s*=\s*(\w*)', options.groups()[0], re.IGNORECASE)
value = re.search(r'constructor\s*=\s*(\w*)', options.groups()[0], re.IGNORECASE)
if value:
self.parser.userTestCase['testParameterConstructor'] = value.groups()[0]
else:
Expand All @@ -621,8 +621,8 @@ def __init__(self, parser):
self.keyword = '@disable'

def match(self, line):
nameRe = "'\w+'|" + """\w+"""
m = re.match("\s*@disable\s*$", line, re.IGNORECASE)
nameRe = r"'\w+'|" + r"""\w+"""
m = re.match(r"\s*@disable\s*$", line, re.IGNORECASE)
return m

def action(self, m, line):
Expand Down Expand Up @@ -711,7 +711,7 @@ def parse(line):
self.makeWrapperModule()

def isComment(self, line):
return re.match('\s*(!.*|)$', line)
return re.match(r'\s*(!.*|)$', line)

def nextLine(self):
while True:
Expand Down
22 changes: 11 additions & 11 deletions tools/overload_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def apply(self, line, state):
return m

class TKR_begin(Action):
regexp = re.compile("\s*@tkr_parameters\s*(\w*)")
regexp = re.compile(r"\s*@tkr_parameters\s*(\w*)")
def action(self, m, line, state):
state.current_tkr = m.group(1)
state.tkr_dictionaries[state.current_tkr] = []
Expand All @@ -147,13 +147,13 @@ class TKR_inside(Action):
def match(self, line, state):
return state.current_tkr # empty string?
def action(self, m, line, state):
rexp = re.compile("\s*\!.*")
rexp = re.compile(r"\s*\!.*")
if re.match(rexp, line):
return
inside = re.compile("\s*\[(.*)\]\s*").match(line).groups(0)[0]
inside = re.compile(r"\s*\[(.*)\]\s*").match(line).groups(0)[0]
params = re.split(r',\s*(?![^()]*\))', inside)
tkrs = [x for x in params if re.compile("\s*\(.*\)\s*").match(x)]
elements = [(re.compile("\((.*)\)").match(x.strip()).groups(0)[0]).split(',') for x in tkrs]
tkrs = [x for x in params if re.compile(r"\s*\(.*\)\s*").match(x)]
elements = [(re.compile(r"\((.*)\)").match(x.strip()).groups(0)[0]).split(',') for x in tkrs]

hash = ''
d = {}
Expand All @@ -170,7 +170,7 @@ def action(self, m, line, state):


class TKR_end(Action):
regexp = re.compile("\s*@end tkr_parameters")
regexp = re.compile(r"\s*@end tkr_parameters")
def action(self, m, line, state):
state.current_tkr = ''

Expand All @@ -181,7 +181,7 @@ def name_mangle(base, items):
return mangle

class Overload(Action):
regexp = re.compile("(\s*)@overload\((\w+),\s*(\w+)\s*\)")
regexp = re.compile(r"(\s*)@overload\((\w+),\s*(\w+)\s*\)")
def action(self, m, line, state):
generic_name = m.group(2)
indent = m.group(1)
Expand All @@ -192,7 +192,7 @@ def action(self, m, line, state):


class Module(Action):
regexp = re.compile("\s*(end)?\s*module\s+\w*\s*")
regexp = re.compile(r"\s*(end)?\s*module\s+\w*\s*")
def action(self, m, line, state):
if state.current_template:
state.templates[state.current_template]['text'] += line
Expand All @@ -201,7 +201,7 @@ def action(self, m, line, state):


class Template_begin(Action):
regexp = re.compile("\s*@template\s*\(\s*(\w+)\s*,\s*\[(.*)\]\s*")
regexp = re.compile(r"\s*@template\s*\(\s*(\w+)\s*,\s*\[(.*)\]\s*")
def action(self, m, line, state):
state.current_template = m.group(1)
parameters = [x.strip() for x in m.group(2).split(',')]
Expand All @@ -214,12 +214,12 @@ def action(self, m, line, state):
state.templates[state.current_template]['text'] += line

class Template_end(Action):
regexp = re.compile("\s*@end template")
regexp = re.compile(r"\s*@end template")
def action(self, m, line, state):
state.current_template = ''

class Instantiate(Action):
regexp = re.compile("\s*@instantiate\(\s*(\w*)\s*,\s*(\w*)\s*\)")
regexp = re.compile(r"\s*@instantiate\(\s*(\w*)\s*,\s*(\w*)\s*\)")
def action(self, m, line, state):
template_name = m.group(1)
template = state.templates[template_name]['text']
Expand Down

0 comments on commit 39990ca

Please sign in to comment.