diff --git a/src/code_.py b/src/code_.py index 513b791929374bee63cef4c735aa98eb510962a6..b7d256de9bd52e843725d8ffc647da0d5f14fdc1 100644 --- a/src/code_.py +++ b/src/code_.py @@ -1,4 +1,4 @@ -from .outils import remove_comments, get_parenthese_count, get_curly_count, get_code_until_parenthese_count, extract_curly +from .outils import remove_comments, get_parenthese_count, get_curly_count, get_code_until_parenthese_count, extract_curly, get_next_element_caracter from .bioflowinsighterror import BioFlowInsightError import re from . import constant @@ -100,6 +100,7 @@ class Code: temp_code = code[start:] for match in re.finditer(pattern, temp_code): if(match.span(0)[0]==0): + _, end_line = match.span(0) found_if_bloc = True all = match.group(0) extarcted = match.group(2).strip() @@ -113,6 +114,12 @@ class Code: if(body!="" and body[0]!="{"): new = f"if ({condition}) {{\n{body}\n}}\n" to_replace.append((all, new)) + elif(body==""): + char, pos = get_next_element_caracter(temp_code, end_line) + if(char!="{"): + raise BioFlowInsightError(f"The condition '({extracted_condition}' was not extracted correctly. Make sure the condition follows the correct syntaxe.", type="Unable to extract condition") + + start+=1