Commit 9f1b80b5 authored by sparonuz's avatar sparonuz
Browse files

Fix for literals

parent 720a9cd1
......@@ -1547,6 +1547,7 @@ def parse_attributes(attributes, variables):
pointer = is_pointer(attributes, variables)
return var_type, dimension, intent, optional, allocatable, pointer, parameter
def split_declaration_arguments(string):
# Description: given a string containing arguments, return a list with arguments
# Input: String with arguments
......@@ -2365,9 +2366,34 @@ def replace_variable_exact_match(piece_to_replace, replacement, str):
piece_to_replace = piece_to_replace.replace(")", "\)")
else:
piece_to_replace = piece_to_replace + "\\b(?!%val)"
piece_to_replace = piece_to_replace + "\\b(?! *\()"
# Replace all occurence outside string
mask = literal_mask(str)
new_string = ""
literal_part = []
literal_substitution = []
literal_to_substitute = ["##", "$$"]
n_of_literal = -1
outside_str = True
for index, i in enumerate(mask):
if not i:
new_string += str[index]
outside_str = True
else:
if outside_str:
n_of_literal += 1
literal_substitution.append([])
literal_part.append([])
outside_str = False
literal_part[n_of_literal].append(str[index])
new_string += literal_to_substitute[n_of_literal % 2]
literal_substitution[n_of_literal].append(literal_to_substitute[n_of_literal % 2])
str = re.sub(piece_to_replace, replacement, new_string)
for index, substitution in enumerate(literal_part):
str = str.replace("".join(literal_substitution[index]), "".join(literal_part[index]), 1)
# Replace string using regex
str = re.sub(piece_to_replace, replacement, str)
return str
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment