Compare commits

...

15 Commits

Author SHA1 Message Date
Anthony Scemama beac615343 Merge branch 'master' of gitlab.com:scemama/irpf90 2024-04-22 11:02:59 +02:00
Anthony Scemama 01899b41b2 Fixed type 2024-04-22 11:02:00 +02:00
Anthony Scemama 451c93a52c Fixed type 2024-04-22 10:58:25 +02:00
Anthony Scemama 76946321d6 Updated regexp for type 2024-04-22 10:44:50 +02:00
Anthony Scemama ba1a2837aa Fix for sphinx functions 2024-03-20 16:05:42 +01:00
Anthony Scemama 4ab1b175fc Updated python -> python3 2023-10-19 17:50:35 +02:00
Anthony Scemama 0007f72f67 Merge branch 'set_parameters' into 'master'
I need to setup my params differently. This is one idea but it requires extra import

See merge request scemama/irpf90!25
2022-11-28 08:07:00 +00:00
Otto Kohulak a885761ea2 Merge branch 'master' into set_parameters 2022-10-21 08:18:44 +02:00
Otto Kohulak 152c69c754 Draft: I need to setup my params differently. This is one idea but it requires extra import 2022-10-20 15:53:38 +02:00
Anthony Scemama 34ca9a7852 Merge branch 'fix_indent_preprocesor_macros' into 'master'
Fix irpf90_indent now does not produce white space lines

See merge request scemama/irpf90!24
2022-10-18 13:12:16 +00:00
Otto Kohulak d1e475dc22 Fix irpf90_indent now does not produce white space lines
Fix C preprocessor macros are now never indented
Fix !$omp directive are now never indeted
2022-10-18 14:06:45 +02:00
Anthony Scemama 088c6fdc04 Merge branch 'fix_indent' into 'master'
Fix indent if line starts with &

See merge request scemama/irpf90!23
2022-10-18 09:47:34 +00:00
Ot(t)o Kohulák c938931e5e Fix indent if line starts with & 2022-10-17 07:21:29 +02:00
Anthony Scemama ab88cc01a6 Fixed regexp for strings with double quotes 2022-01-11 22:44:18 +01:00
Anthony Scemama 33ca5e1018 Shorten lines in ninja file 2021-05-19 18:36:43 +02:00
8 changed files with 50 additions and 10 deletions

View File

@ -3,7 +3,7 @@ RST2MAN=rst2man -d -t
default: man1/irpman.1.gz man1/irpf90.1.gz
options.rst: ../src/command_line.py
python ../src/command_line.py > options.rst
python3 ../src/command_line.py > options.rst
man1/irpf90.1.gz: irpf90.rst options.rst
rm -f $@ ; $(RST2MAN) --title="IRP Fortran 90" irpf90.rst man1/irpf90.1 ; gzip man1/irpf90.1

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA

View File

@ -222,7 +222,7 @@ def do_print_subroutines_rst(sub):
filename = sub.line.filename
name = sub.name
file = open("%s%s.rst"%(mandir,sub.name), "w")
print(".. c:function:: %s:\n"%(sub.name.lower()), file=file)
print(".. c:macro:: %s:\n"%(sub.name.lower()), file=file)
print("", file=file)
print(" File : :file:`"+filename+"`", file=file)
print("", file=file)

View File

@ -26,10 +26,21 @@
import sys
import os
import re
LENMAX = 70
tabn = 2
#copy of locals without "import copy"
locals_ = {x: y for x, y in locals().items()}
for key, value in locals_.items():
try:
val = os.environ["IRPF90_INDENT_"+key.upper()]
locals()[key] = type(locals_[key])(val)
except:
pass
tab = " "*tabn
class Grep(object):
@ -106,6 +117,14 @@ class Grep(object):
def declaration(self,string):
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()
class indent(object):
@ -119,10 +138,12 @@ class indent(object):
return l.strip().ljust(n) + ' :: '+ r.strip()
def format_continuation(self,string,n):
buffer = string.split('&')
buffer = string.split('&', 1)
if len(buffer) == 1:
l = buffer[0]
return l
elif buffer[0].strip() == "":
return self.format_continuation(buffer[1], n)
else:
l, r = buffer
return l.strip().ljust(69-len(n)) + '&'+ r.strip()
@ -165,6 +186,19 @@ class indent(object):
for i in range(len(self.text)):
prevline = line
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):
line = self.format_continuation(line,k)

View File

@ -55,7 +55,8 @@ def dress(f,in_root=False):
result = os.path.join(cwd,f)
else:
result = os.path.join(cwd,irpdir,f)
return os.path.normpath(result)
result = os.path.normpath(result)
return result
def create_build_touches(list_of_other_o):
@ -405,8 +406,12 @@ def run():
output.append(create_build_remaining(i))
text = '\n\n'.join(output)
text = text.replace(cwd+"/IRPF90_temp","$T")
text = text.replace(cwd,"$X")
with open(FILENAME,'w') as f:
f.write('\n\n'.join(output))
f.write("X="+cwd+"\nT="+cwd+"/IRPF90_temp\n")
f.write(text)
f.write('\n')
create_irpf90_make([ x.filename for x in l_targets ] + [ os.path.join(irpdir,'irpf90.a') ] )

View File

@ -323,7 +323,7 @@ def execute_templates(text):
file.close()
# Execute shell
import os
pipe = os.popen("python < %s"%(scriptname),'r')
pipe = os.popen("python3 < %s"%(scriptname),'r')
lines = pipe.readlines()
pipe.close()
result += get_text(lines,scriptname)

View File

@ -46,12 +46,13 @@ re_decl = re.compile( "".join( [ r"^\ *",
r"|intrinsic *(::)?",
r"|external *(::)?",
r"|equivalence *(::)?",
r"|type",
r"|type *\(",
r"|type +",
r"|end ?type",
r")[^=(]"
] ) )
re_test = re.compile(r"\( *(.*)(\.[a-zA-Z]*\.|[<>]=?|[=/]=)([^=]*)\)")
re_string = re.compile(r"'.*?'")
re_string = re.compile(r"'.*?'|\".*?\"")