From d3ff166e7f318ec1745ce5eeb8830f42dab541f4 Mon Sep 17 00:00:00 2001 From: Mohamed Fawzi Date: Mon, 28 Jan 2008 22:58:06 +0000 Subject: [PATCH] bug fixes, pre doxygen * dependencies of arguments on parameters * no splitting of numbers to break lines * BIND(C) routines * implicit (or not parsed) routine arguments * removal of unused variables that are only nullified more agressive (works also if a sub element of a structure is nullified) * removed non optional arg after optional arg warning * minor fixes svn-origin-rev: 6905 --- tools/normalizeFortranFile.py | 47 +++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/tools/normalizeFortranFile.py b/tools/normalizeFortranFile.py index 26750bcd36..48fbe13e45 100755 --- a/tools/normalizeFortranFile.py +++ b/tools/normalizeFortranFile.py @@ -29,20 +29,19 @@ def readFortranLine(infile): while 1: line=infile.readline().replace("\t",8*" ") if not line: break + lines.append(line) m=lineRe.match(line) if not m or m.span()[1]!=len(line): raise SyntaxError("unexpected line format:"+repr(line)) if m.group("preprocessor"): - if len(lines)>0: + if len(lines)>1: raise SyntaxError("continuation to a preprocessor line not supported "+repr(line)) - lines.append(line) comments=line break coreAtt=m.group("core") joinedLine+=coreAtt if coreAtt and not coreAtt.isspace(): continuation=0 if m.group("continue"): continuation=1 - lines.append(line) if m.group("comment"): if comments: comments+="\n"+m.group("comment") @@ -55,10 +54,10 @@ def parseRoutine(inFile): """Parses a routine""" startRe=re.compile(r" *(?:recursive +|pure +|elemental +)*(?:subroutine|function)",re.IGNORECASE) endRe=re.compile(r" *end (?:subroutine|function)",re.IGNORECASE) - startRoutineRe=re.compile(r" *(?:recursive +|pure +|elemental +)*(?Psubroutine|function) +(?P[a-zA-Z_][a-zA-Z_0-9]*) *(?:\((?P[^()]*)\))? *(?:result *\( *(?P[a-zA-Z_][a-zA-Z_0-9]*) *\))? *\n?",re.IGNORECASE)#$ + startRoutineRe=re.compile(r" *(?:recursive +|pure +|elemental +)*(?Psubroutine|function) +(?P[a-zA-Z_][a-zA-Z_0-9]*) *(?:\((?P[^()]*)\))? *(?:result *\( *(?P[a-zA-Z_][a-zA-Z_0-9]*) *\))? *(?:bind *\([^()]+\))? *\n?",re.IGNORECASE)#$ typeBeginRe=re.compile(r" *(?Pinteger(?: *\* *[0-9]+)?|logical|character(?: *\* *[0-9]+)?|real(?: *\* *[0-9]+)?|complex(?: *\* *[0-9]+)?|type)", re.IGNORECASE) - typeRe=re.compile(r" *(?Pinteger(?: *\* *[0-9]+)?|logical|character(?: *\* *[0-9]+)?|real(?: *\* *[0-9]+)?|complex(?: *\* *[0-9]+)?|type) *(?P\((?:[^()]+|\([^()]*\))*\))? *(?P(?: *, *[a-zA-Z_0-9]+(?: *\((?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*\))?)+)? *(?P::)?(?P[^\n]+)\n?",re.IGNORECASE)#$ + typeRe=re.compile(r" *(?Pinteger(?: *\* *[0-9]+)?|logical|character(?: *\* *[0-9]+)?|real(?: *\* *[0-9]+)?|complex(?: *\* *[0-9]+)?|type) *(?P\((?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*\))? *(?P(?: *, *[a-zA-Z_0-9]+(?: *\((?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*\))?)+)? *(?P::)?(?P[^\n]+)\n?",re.IGNORECASE)#$ attributeRe=re.compile(r" *, *(?P[a-zA-Z_0-9]+) *(?:\( *(?P(?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*)\))? *",re.IGNORECASE) ignoreRe=re.compile(r" *(?:|implicit +none *)$",re.IGNORECASE) interfaceStartRe=re.compile(r" *interface *$",re.IGNORECASE) @@ -304,7 +303,7 @@ def writeInCols(dLine,indentCol,maxCol,indentAtt,file): The '&' of the continuation line is at maxCol. indentAtt is the actual intent, and the new indent is returned""" strRe=re.compile(r"('[^'\n]*'|\"[^\"\n]*\")") - nonWordRe=re.compile(r"([^a-zA-Z0-9_.])") + nonWordRe=re.compile(r"(\((?!/)|(?