10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-11-09 15:43:43 +01:00

Added +=, -=, *= operators

This commit is contained in:
Anthony Scemama 2009-12-09 16:48:48 +01:00
parent ef72d18ddd
commit bc137dc4a1

View File

@ -252,6 +252,24 @@ def form(text):
return Free_form return Free_form
return Fixed_form return Fixed_form
######################################################################
def add_operators(text):
re_incr = re.compile(r"(\s*)(.*)(\+=)(.*$)",re.S)
re_decr = re.compile(r"(\s*)(.*)(-=)(.*$)",re.S)
re_mult = re.compile(r"(\s*)(.*)(\*=)(.*$)",re.S)
'''Change additional operators'''
result = []
for line in text:
buffer = line.text
if "+=" in buffer:
line.text = re.sub(re_incr,r'\1\2=\2+(\4)', buffer)
elif "-=" in buffer:
line.text = re.sub(re_decr,r'\1\2=\2-(\4)', buffer)
elif "*=" in buffer:
line.text = re.sub(re_mult,r'\1\2=\2*(\4)', buffer)
result.append(line)
return result
###################################################################### ######################################################################
def remove_comments(text,form): def remove_comments(text,form):
'''Remove all comments''' '''Remove all comments'''
@ -717,6 +735,7 @@ def create_preprocessed_text(filename):
result = remove_ifdefs(result) result = remove_ifdefs(result)
result = remove_comments(result,fortran_form) result = remove_comments(result,fortran_form)
result = remove_continuation(result,fortran_form) result = remove_continuation(result,fortran_form)
result = add_operators(result)
result = change_includes(result) result = change_includes(result)
result = change_single_line_ifs(result) result = change_single_line_ifs(result)
result = process_old_style_do(result) result = process_old_style_do(result)