10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2025-01-03 10:05:40 +01:00

Fix comment and Makefile

This commit is contained in:
Thomas Applencourt 2017-01-20 14:59:53 -06:00
parent c4fda3330e
commit 763278756b
4 changed files with 48 additions and 21 deletions

View File

@ -319,7 +319,7 @@ r""]
" $(BUILD_SYSTEM) -C $(dir $(1) ) -f $(notdir $(1) ) $(addprefix $(CURDIR)/, $(2)) && touch $(2)", " $(BUILD_SYSTEM) -C $(dir $(1) ) -f $(notdir $(1) ) $(addprefix $(CURDIR)/, $(2)) && touch $(2)",
"endef", "endef",
"", "",
"EXE := $(shell egrep -r '^\s*program' *.irp.f | awk '{print $$2}')", "EXE := $(shell egrep -ri '^\s*program' *.irp.f | cut -d'.' -f1)",
"", "",
".PHONY: all", ".PHONY: all",
"", "",

View File

@ -86,6 +86,7 @@ def main():
comm_world.create_touches() comm_world.create_touches()
comm_world.create_man() comm_world.create_man()
print 'Done'
if command_line.do_profile: if command_line.do_profile:
import profile import profile
profile.run() profile.run()

View File

@ -249,7 +249,6 @@ def execute_shell(text):
assert n >= 1, fail(header_text, "Missing", bracket) assert n >= 1, fail(header_text, "Missing", bracket)
else: else:
interpreter = header_text[header_text.find('[')+1: header_text.find(']')].strip() interpreter = header_text[header_text.find('[')+1: header_text.find(']')].strip()
script = ['%s\n' % l.text for l in text[begin+1:end] ] script = ['%s\n' % l.text for l in text[begin+1:end] ]
scriptname="%s_shell_%d" % (header.filename, header.i) scriptname="%s_shell_%d" % (header.filename, header.i)
@ -399,15 +398,34 @@ def add_operators(text):
###################################################################### ######################################################################
def remove_comments(text, form): def remove_comments(text, form):
# (List[Line], int) -> List[Line] # (List[Line], int) -> List[Line]
'''Remove all comments''' '''Remove all comments
Note:
This function is unpur
'''
result = [] result = []
def remove_after_bang(line): def remove_after_bang(str_):
match = re_comment.match(line) # str -> str
if not match: i_bang = str_.find('!')
return line
else: if i_bang == -1:
return ''.join(str_ for str_ in match.groups() if str_).rstrip() return str_
else:
sentinel, inside = None, False
for i,c in enumerate(str_):
if c == '"' or c == "'":
if not inside:
inside = True
sentinel = c
elif sentinel == c:
inside = False
elif c == '!' and not inside:
return str_[:i]
return str_
if form == Free_form: if form == Free_form:
for line in text: for line in text:
@ -417,11 +435,11 @@ def remove_comments(text, form):
pass pass
else: else:
newline = line.text.lstrip() newline = line.text.lstrip()
if newline == "" or newline[0] == "!": if (newline != "" and newline[0] != "!#"):
pass text = remove_after_bang(line.text)
else: if text:
line.text = remove_after_bang(line.text) line.text = text
result.append(line) result.append(line)
return result return result
else: else:
@ -574,8 +592,8 @@ def irp_simple_statements(text):
return result return result
def process_end(line): def process_end(line):
'''Set irp_here variable in provider block''' '''Add irp_leave if necessary'''
line.text = "end"
if command_line.do_assert or command_line.do_debug: if command_line.do_assert or command_line.do_debug:
i = line.i i = line.i
f = line.filename f = line.filename
@ -820,17 +838,16 @@ def check_begin_end(raw_text):
for line in raw_text: for line in raw_text:
d_type[type(line)].append(line) d_type[type(line)].append(line)
for t_end, l_begin in d_block.iteritems(): for t_end, l_begin in d_block.iteritems():
n_end = len(d_type[t_end]) n_end = len(d_type[t_end])
n_begin = sum(len(d_type[t_begin]) for t_begin in l_begin) n_begin = sum(len(d_type[t_begin]) for t_begin in l_begin)
if n_end > n_begin: if n_end > n_begin:
logger.warning("You have maybe more close statement than open statement (%s) (%s)",line.filename,t_end) logger.error("You have more close statement than open statement (%s) (%s)",line.filename,t_end)
sys.exit(1) sys.exit(1)
elif n_end < n_begin: elif n_end < n_begin:
logger.warning('You have mayble more end statement than open statenemt for (%s) (%s)' % (line.filename, t_end)) logger.error('You have more end statement than open statenemt for (%s) (%s)' % (line.filename, t_end))
sys.exit(1) sys.exit(1)
###################################################################### ######################################################################
@ -881,7 +898,15 @@ class Preprocess_text(object):
@irpy.lazy_property_mutable @irpy.lazy_property_mutable
def text(self): def text(self):
with open(self.filename, 'r') as f: with open(self.filename, 'r') as f:
return f.read() str_ = f.read()
#Dirty thing. We will replace 'end program' by 'end subroutine'
#because afterward the program will be replaced by a subroutine...
import re
transform = re.compile(re.escape('end program'), re.IGNORECASE)
return transform.sub('end subroutine', str_)
@irpy.lazy_property_mutable @irpy.lazy_property_mutable
def text_align(self): def text_align(self):
@ -938,6 +963,7 @@ class Preprocess_text(object):
result = check_OpenMP(result) result = check_OpenMP(result)
check_begin_end(result) check_begin_end(result)
return result return result

View File

@ -55,7 +55,7 @@ def chunkify(l,n_chunk):
import multiprocessing import multiprocessing
def parmap(f, it, parallel=True): def parmap(f, it, parallel=False):
# (Callable, Iterable, bool) -> List # (Callable, Iterable, bool) -> List
'''Parallel version of the std map function '''Parallel version of the std map function