diff --git a/src/build_file.py b/src/build_file.py index c4428ab..b856367 100644 --- a/src/build_file.py +++ b/src/build_file.py @@ -319,7 +319,7 @@ r""] " $(BUILD_SYSTEM) -C $(dir $(1) ) -f $(notdir $(1) ) $(addprefix $(CURDIR)/, $(2)) && touch $(2)", "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", "", diff --git a/src/irpf90.py b/src/irpf90.py index 21fb198..d716b39 100644 --- a/src/irpf90.py +++ b/src/irpf90.py @@ -86,6 +86,7 @@ def main(): comm_world.create_touches() comm_world.create_man() + print 'Done' if command_line.do_profile: import profile profile.run() diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index f00cdc1..6fbece7 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -249,7 +249,6 @@ def execute_shell(text): assert n >= 1, fail(header_text, "Missing", bracket) else: interpreter = header_text[header_text.find('[')+1: header_text.find(']')].strip() - script = ['%s\n' % l.text for l in text[begin+1:end] ] scriptname="%s_shell_%d" % (header.filename, header.i) @@ -399,15 +398,34 @@ def add_operators(text): ###################################################################### def remove_comments(text, form): # (List[Line], int) -> List[Line] - '''Remove all comments''' + '''Remove all comments + + Note: + This function is unpur + ''' result = [] - def remove_after_bang(line): - match = re_comment.match(line) - if not match: - return line - else: - return ''.join(str_ for str_ in match.groups() if str_).rstrip() + def remove_after_bang(str_): + # str -> str + i_bang = str_.find('!') + + if i_bang == -1: + 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: for line in text: @@ -417,11 +435,11 @@ def remove_comments(text, form): pass else: newline = line.text.lstrip() - if newline == "" or newline[0] == "!": - pass - else: - line.text = remove_after_bang(line.text) - result.append(line) + if (newline != "" and newline[0] != "!#"): + text = remove_after_bang(line.text) + if text: + line.text = text + result.append(line) return result else: @@ -574,8 +592,8 @@ def irp_simple_statements(text): return result def process_end(line): - '''Set irp_here variable in provider block''' - line.text = "end" + '''Add irp_leave if necessary''' + if command_line.do_assert or command_line.do_debug: i = line.i f = line.filename @@ -820,17 +838,16 @@ def check_begin_end(raw_text): for line in raw_text: d_type[type(line)].append(line) - for t_end, l_begin in d_block.iteritems(): n_end = len(d_type[t_end]) n_begin = sum(len(d_type[t_begin]) for t_begin in l_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) 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) ###################################################################### @@ -881,7 +898,15 @@ class Preprocess_text(object): @irpy.lazy_property_mutable def text(self): 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 def text_align(self): @@ -938,6 +963,7 @@ class Preprocess_text(object): result = check_OpenMP(result) check_begin_end(result) + return result diff --git a/src/util.py b/src/util.py index 3d44d1e..c3e1656 100644 --- a/src/util.py +++ b/src/util.py @@ -55,7 +55,7 @@ def chunkify(l,n_chunk): import multiprocessing -def parmap(f, it, parallel=True): +def parmap(f, it, parallel=False): # (Callable, Iterable, bool) -> List '''Parallel version of the std map function