Commit ea4bd57e authored by erodrigu's avatar erodrigu
Browse files

Moved the regex patterns to RegexPattern.py

parent 1b0a4376
......@@ -6,6 +6,7 @@ from AutoRPE.UtilsRPE.Inserter import replace_real_declaration
from AutoRPE.UtilsRPE.SourceManager import preprocess_sources, parse_sources, load_vault
from AutoRPE.UtilsRPE.Cleaner import remove_comments
from AutoRPE.UtilsRPE.Finder import find_declaration_line
import AutoRPE.UtilsRPE.RegexPattern as re_pattern
from argparse import ArgumentParser
from os import mkdir
......@@ -57,7 +58,7 @@ def merge_declaration_lines(code_text):
def replace_subroutine_name(old_name, new_name, code_text):
pattern = r"(subroutine +\b)%s\b" % old_name
pattern = re_pattern.subroutine_declaration % old_name
pat = re.compile(pattern, re.I)
replacement = r"\1 %s" % new_name
return pat.sub(replacement, code_text)
......@@ -67,7 +68,7 @@ def obtain_routine_source(routine, sources_path):
source_file = join(sources_path, "%s.f90" % routine.module.name)
indices = []
with open(source_file) as f:
pattern = r"routine.*\b%s\b" % routine.name
pattern = re_pattern.subroutine_declaration % routine.name
lines = [l for l in f]
for index, line in enumerate(lines):
......@@ -81,7 +82,7 @@ def obtain_routine_source(routine, sources_path):
def replace_routine_name(old_name, new_name, code_text):
pattern = r"(subroutine +\b)%s\b" % old_name
pattern = re_pattern.subroutine_declaration % old_name
pat = re.compile(pattern, re.I)
replacement = r"\1 %s" % new_name
return pat.sub(replacement, code_text)
......
......@@ -52,4 +52,7 @@ pure_real_declaration = '^\s*\w?(real).*(::|(function))'
# - group 0 => eventual ptr attributes
# - group 2 => ptr
# - group 3 => target
pointers_assignation = "(.*::|)\s*(.*)=>\s*(.*)"
\ No newline at end of file
pointers_assignation = "(.*::|)\s*(.*)=>\s*(.*)"
# subroutine subroutine_name
subroutine_declaration = r"(subroutine +\b)%s\b"
\ No newline at end of file
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