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

Fixed regexp

This commit is contained in:
Anthony Scemama 2017-09-18 15:14:18 +02:00
parent de308abded
commit cd4be303cc

View File

@ -362,6 +362,9 @@ 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)
re_incr_if = re.compile(r"(.*)(\))(\s*)(.*)(\+=)(.*$)", re.S)
re_decr_if = re.compile(r"(.*)(\))(\s*)(.*)(-=)(.*$)", re.S)
re_mult_if = re.compile(r"(.*)(\))(\s*)(.*)(\*=)(.*$)", re.S)
'''Change additional operators'''
result = []
for line in text:
@ -371,11 +374,15 @@ def add_operators(text):
ls.startswith('print*') or \
ls.startswith('write('):
pass
elif "+=" in buffer:
if buffer.lstrip().startswith("if "):
re_incr = re.compile(r"(.*)(\))(\s*)(.*)(\+=)(.*$)",re.S)
line.text = re.sub(re_incr,r'\1\2\4=\4+(\6)', buffer)
elif buffer.lstrip().startswith("if "):
if "+=" in buffer:
line.text = re.sub(re_incr_if, r'\1\2\4=\4+(\6)', buffer)
elif "-=" in buffer:
line.text = re.sub(re_incr_if, r'\1\2\4=\4-(\6)', buffer)
elif "*=" in buffer:
line.text = re.sub(re_incr_if, r'\1\2\4=\4*(\6)', buffer)
else:
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)