10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-12-22 12:23:32 +01:00

Merge branch 'fix_indent_preprocesor_macros' into 'master'

Fix irpf90_indent now does not produce white space lines

See merge request scemama/irpf90!24
This commit is contained in:
Anthony Scemama 2022-10-18 13:12:16 +00:00
commit 34ca9a7852

View File

@ -106,6 +106,14 @@ class Grep(object):
def declaration(self,string): def declaration(self,string):
return re.match(self.re_declaration,string) is not None return re.match(self.re_declaration,string) is not None
re_preprocessor = re.compile(r"^\s*#.*$")
def preprocessor(self,string):
return re.match(self.re_preprocessor,string) is not None
re_omppragma = re.compile(r"^\s*!\$omp\s.*$")
def omppragma(self,string):
return re.match(self.re_omppragma,string) is not None
grep = Grep() grep = Grep()
class indent(object): class indent(object):
@ -167,6 +175,19 @@ class indent(object):
for i in range(len(self.text)): for i in range(len(self.text)):
prevline = line prevline = line
line = self.text[i].strip() line = self.text[i].strip()
if line == "":
print("")
continue
if grep.preprocessor(line):
print(line.lstrip())
continue
if grep.omppragma(line):
print(line.lstrip())
continue
if grep.continuation(line): if grep.continuation(line):
line = self.format_continuation(line,k) line = self.format_continuation(line,k)