From 9a41413750b35f36bf81bdee26d2276591c3ed44 Mon Sep 17 00:00:00 2001 From: Nuno Jesus Date: Sat, 19 Nov 2022 02:40:33 +0000 Subject: [PATCH] Fixed a bug where tokenization would fail in case of multiple tabs between function name and function type. --- utils.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/utils.py b/utils.py index 68cbbfa..b3045b3 100644 --- a/utils.py +++ b/utils.py @@ -1,4 +1,5 @@ import os +import re import copy import random import subprocess @@ -7,7 +8,7 @@ from colorama import Fore # INSERT YOUR PATH HERE, INSIDE QUOTES -path = '../42-cursus/libft/' +path = '../libft/' # Used colors across the files RESET = Style.RESET_ALL @@ -39,18 +40,17 @@ } def tokenize(str): - str = str.replace("\t", " ") - str = str.replace(" **", "** ") - str = str.replace(" *", "* ") - str = str.replace("( ", "(") - str = str.replace(" )", ")") - str = str.replace("(", " ") - str = str.replace(")", " ") - str = str.replace(" ,", ",") + str = re.sub('\t+', ' ', str) + str = str.replace(' **', '** ') + str = str.replace(' *', '* ') + str = str.replace('( ', '(') + str = str.replace(' )', ')') + str = str.replace('(', ' ') + str = str.replace(')', ' ') + str = str.replace(' ,', ',') res = str.split(' ') res = list(filter(lambda x : x != '', res)) - #print(res) return res