mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-12-21 11:53:32 +01:00
Fixed regexp
This commit is contained in:
parent
de308abded
commit
cd4be303cc
@ -359,9 +359,12 @@ def form(text):
|
||||
|
||||
######################################################################
|
||||
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 = 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:
|
||||
@ -370,17 +373,21 @@ def add_operators(text):
|
||||
if ls.startswith('print ') or \
|
||||
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)
|
||||
else:
|
||||
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)
|
||||
pass
|
||||
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)
|
||||
elif "*=" in buffer:
|
||||
line.text = re.sub(re_mult, r'\1\2=\2*(\4)', buffer)
|
||||
result.append(line)
|
||||
return result
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user