diff --git a/norminette/lexer/lexer.py b/norminette/lexer/lexer.py index ff6edc8f..c0b73c0c 100644 --- a/norminette/lexer/lexer.py +++ b/norminette/lexer/lexer.py @@ -54,7 +54,7 @@ def pop_char(self, skip_escaped=True): if self.peek_char() == "\t": self.__line_pos += 4 - (self.__line_pos - 1 & 3) else: - self.__line_pos += 1 + self.__line_pos += len(self.peek_char()) if self.__pos < self.len and skip_escaped and self.src[self.__pos] == "\\": self.__pos += 1 self.__pos += 1 diff --git a/tests/rules/samples/test_file_2007.c b/tests/rules/samples/test_file_2007.c new file mode 100644 index 00000000..a8a72864 --- /dev/null +++ b/tests/rules/samples/test_file_2007.c @@ -0,0 +1,14 @@ +int philo(int argc, char const *argv[], char *const envp[]) +{ + char *str; + + if (argc != 1) + { + ft_putstr("\033[0;33mUsage: ./philo number_of_philosophers time_to_die"); + ft_putstr("time_to_eat time_to_sleep [number_of_times_each_philosopher"); + ft_putstr("_must_eat]\033[0m\n"); + ft_putstr("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + ft_putstr("time_to_eat time_to_sleep [number_of_times_each_philosopher"); + } + (void) argv; +} diff --git a/tests/rules/samples/test_file_2007.out b/tests/rules/samples/test_file_2007.out new file mode 100644 index 00000000..315fcbe4 --- /dev/null +++ b/tests/rules/samples/test_file_2007.out @@ -0,0 +1,35 @@ +test_file_2007.c - IsFuncDeclaration In "GlobalScope" from "None" line 1": + +test_file_2007.c - IsBlockStart In "Function" from "GlobalScope" line 2": + +test_file_2007.c - IsVarDeclaration In "Function" from "GlobalScope" line 3": + +test_file_2007.c - IsEmptyLine In "Function" from "GlobalScope" line 4": + +test_file_2007.c - IsControlStatement In "Function" from "GlobalScope" line 5": + +test_file_2007.c - IsBlockStart In "ControlStructure" from "Function" line 6": + +test_file_2007.c - IsFunctionCall In "ControlStructure" from "Function" line 7": + +test_file_2007.c - IsFunctionCall In "ControlStructure" from "Function" line 8": + +test_file_2007.c - IsFunctionCall In "ControlStructure" from "Function" line 9": + +test_file_2007.c - IsFunctionCall In "ControlStructure" from "Function" line 10": + +test_file_2007.c - IsFunctionCall In "ControlStructure" from "Function" line 11": + +test_file_2007.c - IsBlockEnd In "ControlStructure" from "Function" line 12": + +test_file_2007.c - IsExpressionStatement In "Function" from "GlobalScope" line 13": + +test_file_2007.c - IsBlockEnd In "Function" from "GlobalScope" line 14": + +test_file_2007.c: Error! +Error: INVALID_HEADER (line: 1, col: 1): Missing or invalid 42 header +Error: SPACE_REPLACE_TAB (line: 3, col: 9): Found space when expecting tab +Error: LINE_TOO_LONG (line: 7, col: 82): line too long +Error: LINE_TOO_LONG (line: 8, col: 82): line too long +Error: LINE_TOO_LONG (line: 10, col: 117): line too long +Error: LINE_TOO_LONG (line: 11, col: 82): line too long diff --git a/tests/rules/samples/test_file_210923.out b/tests/rules/samples/test_file_210923.out index 84d526ea..623931f7 100644 --- a/tests/rules/samples/test_file_210923.out +++ b/tests/rules/samples/test_file_210923.out @@ -223,8 +223,8 @@ Error: MULT_ASSIGN_LINE (line: 6, col: 16): Multiple assignations on a si Error: INCLUDE_START_FILE (line: 9, col: 1): Include must be at the start of file Error: TOO_FEW_TAB (line: 15, col: 13): Missing tabs for indent level Error: TOO_MANY_INSTR (line: 15, col: 13): Too many instructions on a single line -Error: TOO_FEW_TAB (line: 23, col: 23): Missing tabs for indent level -Error: TOO_MANY_INSTR (line: 23, col: 23): Too many instructions on a single line +Error: TOO_FEW_TAB (line: 23, col: 24): Missing tabs for indent level +Error: TOO_MANY_INSTR (line: 23, col: 24): Too many instructions on a single line Error: TOO_FEW_TAB (line: 31, col: 12): Missing tabs for indent level Error: TOO_MANY_INSTR (line: 31, col: 12): Too many instructions on a single line Error: TOO_MANY_FUNCS (line: 47, col: 1): Too many functions in file