From 2d88c1bbcb9fc9a0a618a954e27784f5ab755571 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Thu, 20 Jun 2024 08:56:32 +0200 Subject: [PATCH] Fix initialization and formatting of output --- ft_parse/ft_parse.c | 9 +++++---- ft_parse/ft_print_parsing_table.c | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ft_parse/ft_parse.c b/ft_parse/ft_parse.c index 968e2ce..a1eb575 100644 --- a/ft_parse/ft_parse.c +++ b/ft_parse/ft_parse.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/20 20:51:36 by ljiriste #+# #+# */ -/* Updated: 2024/06/16 10:26:21 by ljiriste ### ########.fr */ +/* Updated: 2024/06/16 18:27:16 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -211,6 +211,7 @@ static int add_line(t_vec *states, const char *line, size_t lookahead_size) condensed_line = ft_remove_space(line); state.lookahead = parse_lookahead(condensed_line, lookahead_size); + i = 0; while (lookahead_size > 0) { while (condensed_line[i] && condensed_line[i] != ';') @@ -250,13 +251,13 @@ static t_vec parse_header(const char *header) i = 0; while (condensed_line[i] && condensed_line[i] != ';') ++i; - if (condensed_line[i]) - ++i; while (condensed_line[i]) { + ++i; token.type = get_token_type(condensed_line + i); + while (condensed_line[i] && condensed_line[i] != ';') + ++i; ft_vec_append(&tokens, &token); - ++i; } free(condensed_line); return (tokens); diff --git a/ft_parse/ft_print_parsing_table.c b/ft_parse/ft_print_parsing_table.c index e864b7e..a13915e 100644 --- a/ft_parse/ft_print_parsing_table.c +++ b/ft_parse/ft_print_parsing_table.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/16 07:19:50 by ljiriste #+# #+# */ -/* Updated: 2024/06/16 08:17:46 by ljiriste ### ########.fr */ +/* Updated: 2024/06/16 18:20:37 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -47,7 +47,7 @@ static void print_state(t_parser_state *state, t_vec *vec; ssize_t *gt; - ft_printf("%-*u ", column_width, state_num); + ft_printf("%-5u ", state_num); vec = &state->lookahead; i = 0; while (i < vec->size) @@ -77,9 +77,9 @@ void ft_print_parsing_table(t_parsing_table *table, while (i < table->rules.size) print_rule(ft_vec_access(&table->rules, i++), column_width); i = 0; - ft_printf("\n%-*s ", column_width, "State"); + ft_printf("\n%-5s ", "State"); while (i < table->tokens.size) - ft_printf("%-*s ", column_width, + ft_printf("%-*s ", column_width - 1, ((t_token *)ft_vec_access(&table->tokens, i++))->type); ft_printf("\n"); i = 0; -- 2.30.2