Fixed some stuff
This commit is contained in:
parent
8dbbfcf124
commit
9029af81b6
6 changed files with 98 additions and 30 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/30 17:26:13 by rparodi #+# #+# */
|
||||
/* Updated: 2024/07/30 18:32:26 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/07/30 18:39:53 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ void ast_alloc_other(t_ast_node_kind kind, t_ast_node ret)
|
|||
|
||||
t_ast_node ast_alloc(t_ast_node_kind kind)
|
||||
{
|
||||
void ret;
|
||||
t_ast_node ret;
|
||||
|
||||
ret = mem_alloc(sizeof(*ret));
|
||||
ret->kind = kind;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/30 14:29:42 by rparodi #+# #+# */
|
||||
/* Updated: 2024/07/30 14:58:13 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/30 18:24:41 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
#include "parser/api.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ast_free_arith(t_ast_node elem);
|
||||
void ast_free_condition(t_ast_node elem);
|
||||
void ast_free_exec(t_ast_node elem);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/26 10:55:52 by rparodi #+# #+# */
|
||||
/* Updated: 2024/07/30 17:26:52 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/07/30 18:20:33 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -74,6 +74,8 @@ sym_while_statement
|
|||
sym_word
|
||||
*/
|
||||
|
||||
t_ast_node ast_alloc(t_ast_node_kind kind);
|
||||
|
||||
void ast_set_term(t_ast_node *node, t_ast_terminator_kind term)
|
||||
{
|
||||
t_ast_terminator_kind void_storage;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/17 13:04:32 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/26 15:26:41 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/30 18:30:47 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,18 +16,24 @@
|
|||
#include "me/types.h"
|
||||
#include <stdio.h>
|
||||
|
||||
t_error _build_not_finished(t_parse_node self, t_const_str input, t_ast_node *out)
|
||||
t_error _build_not_finished(t_parse_node self, t_const_str i, t_ast_node *out)
|
||||
{
|
||||
(void)(self);
|
||||
(void)(out);
|
||||
(void)(input);
|
||||
printf("building undefined symbol '%s'\n", ts_node_grammar_type(self));
|
||||
(void)(i);
|
||||
printf("building undefined symbol '%s'\n", ts_node_type(self));
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
t_error __attribute__((weak, alias("_build_not_finished"))) build_sym_heredoc_body(t_parse_node self, t_const_str input, t_ast_node *out);
|
||||
t_error __attribute__((weak, alias("_build_not_finished"))) build_sym_heredoc_content(t_parse_node self, t_const_str input, t_ast_node *out);
|
||||
t_error __attribute__((weak, alias("_build_not_finished"))) build_sym_heredoc_end(t_parse_node self, t_const_str input, t_ast_node *out);
|
||||
t_error __attribute__((weak, alias("_build_not_finished"))) build_sym_heredoc_redirect(t_parse_node self, t_const_str input, t_ast_node *out);
|
||||
t_error __attribute__((weak, alias("_build_not_finished"))) build_sym_heredoc_start(t_parse_node self, t_const_str input, t_ast_node *out);
|
||||
t_error __attribute__((weak, alias("_build_not_finished"))) build_sym_simple_heredoc_body(t_parse_node self, t_const_str input, t_ast_node *out);
|
||||
t_error build_sym_heredoc_body(t_parse_node self, t_const_str input, \
|
||||
t_ast_node *out) __attribute__((weak, alias("_build_not_finished")));
|
||||
t_error build_sym_heredoc_content(t_parse_node self, t_const_str input, \
|
||||
t_ast_node *out) __attribute__((weak, alias("_build_not_finished")));
|
||||
t_error build_sym_heredoc_end(t_parse_node self, t_const_str input, \
|
||||
t_ast_node *out) __attribute__((weak, alias("_build_not_finished")));
|
||||
t_error build_sym_heredoc_redirect(t_parse_node self, t_const_str input, \
|
||||
t_ast_node *out) __attribute__((weak, alias("_build_not_finished")));
|
||||
t_error build_sym_heredoc_start(t_parse_node self, t_const_str input, \
|
||||
t_ast_node *out) __attribute__((weak, alias("_build_not_finished")));
|
||||
t_error build_sym_simple_heredoc_body(t_parse_node self, t_const_str input, \
|
||||
t_ast_node *out) __attribute__((weak, alias("_build_not_finished")));
|
||||
|
|
|
|||
|
|
@ -6,20 +6,62 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/26 11:00:25 by rparodi #+# #+# */
|
||||
/* Updated: 2024/07/30 17:01:04 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/30 18:24:16 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ast/_function_declaration.h"
|
||||
|
||||
#define NOT_DONE {printf("This function is not done '%s'", __func__); (void)(self);}
|
||||
void ast_print_node_if(t_ast_node self)
|
||||
{
|
||||
printf("This function is not done '%s'", __func__);
|
||||
(void)(self);
|
||||
}
|
||||
|
||||
void ast_print_node_if(t_ast_node self) NOT_DONE;
|
||||
void ast_print_node_case(t_ast_node self) NOT_DONE;
|
||||
void ast_print_node_case_item(t_ast_node self) NOT_DONE;
|
||||
void ast_print_node_elif(t_ast_node self) NOT_DONE;
|
||||
void ast_print_node_else(t_ast_node self) NOT_DONE;
|
||||
void ast_print_node_for(t_ast_node self) NOT_DONE;
|
||||
void ast_print_node_until(t_ast_node self) NOT_DONE;
|
||||
void ast_print_node_while(t_ast_node self) NOT_DONE;
|
||||
void ast_print_node_heredoc_redirection(t_ast_node self) NOT_DONE;
|
||||
void ast_print_node_case(t_ast_node self)
|
||||
{
|
||||
printf("This function is not done '%s'", __func__);
|
||||
(void)(self);
|
||||
}
|
||||
|
||||
void ast_print_node_case_item(t_ast_node self)
|
||||
{
|
||||
printf("This function is not done '%s'", __func__);
|
||||
(void)(self);
|
||||
}
|
||||
|
||||
void ast_print_node_elif(t_ast_node self)
|
||||
{
|
||||
printf("This function is not done '%s'", __func__);
|
||||
(void)(self);
|
||||
}
|
||||
|
||||
void ast_print_node_else(t_ast_node self)
|
||||
{
|
||||
printf("This function is not done '%s'", __func__);
|
||||
(void)(self);
|
||||
}
|
||||
|
||||
void ast_print_node_for(t_ast_node self)
|
||||
{
|
||||
printf("This function is not done '%s'", __func__);
|
||||
(void)(self);
|
||||
}
|
||||
|
||||
void ast_print_node_until(t_ast_node self)
|
||||
{
|
||||
printf("This function is not done '%s'", __func__);
|
||||
(void)(self);
|
||||
}
|
||||
|
||||
void ast_print_node_while(t_ast_node self)
|
||||
{
|
||||
printf("This function is not done '%s'", __func__);
|
||||
(void)(self);
|
||||
}
|
||||
|
||||
void ast_print_node_heredoc_redirection(t_ast_node self)
|
||||
{
|
||||
printf("This function is not done '%s'", __func__);
|
||||
(void)(self);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/03 20:38:29 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/26 13:33:00 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/07/30 18:38:50 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -41,10 +41,12 @@ t_ast_while while_;
|
|||
t_ast_word word;
|
||||
*/
|
||||
|
||||
void ast_print_node(t_ast_node self)
|
||||
static inline void ast_print_block1(t_ast_node self);
|
||||
static inline void ast_print_block2(t_ast_node self);
|
||||
static inline void ast_print_block3(t_ast_node self);
|
||||
|
||||
static inline void ast_print_block1(t_ast_node self)
|
||||
{
|
||||
if (self == NULL)
|
||||
return ((void)printf("ast == NULL\n"));
|
||||
if (self->kind == AST_ARITHMETIC_EXPANSION)
|
||||
return (ast_print_node_arithmetic_expansion(self));
|
||||
if (self->kind == AST_CASE)
|
||||
|
|
@ -63,6 +65,11 @@ void ast_print_node(t_ast_node self)
|
|||
return (ast_print_node_else(self));
|
||||
if (self->kind == AST_EMPTY)
|
||||
return ;
|
||||
ast_print_block2(self);
|
||||
}
|
||||
|
||||
static inline void ast_print_block2(t_ast_node self)
|
||||
{
|
||||
if (self->kind == AST_EXPANSION)
|
||||
return (ast_print_node_expansion(self));
|
||||
if (self->kind == AST_EXTGLOB)
|
||||
|
|
@ -73,12 +80,19 @@ void ast_print_node(t_ast_node self)
|
|||
return (ast_print_node_for(self));
|
||||
if (self->kind == AST_FUNCTION_DEFINITION)
|
||||
return (ast_print_node_function_definition(self));
|
||||
if (self == NULL)
|
||||
return ((void)printf("ast == NULL\n"));
|
||||
if (self->kind == AST_HEREDOC_REDIRECTION)
|
||||
return (ast_print_node_heredoc_redirection(self));
|
||||
if (self->kind == AST_IF)
|
||||
return (ast_print_node_if(self));
|
||||
if (self->kind == AST_LIST)
|
||||
return (ast_print_node_list(self));
|
||||
ast_print_block3(self);
|
||||
}
|
||||
|
||||
static inline void ast_print_block3(t_ast_node self)
|
||||
{
|
||||
if (self->kind == AST_PIPELINE)
|
||||
return (ast_print_node_pipeline(self));
|
||||
if (self->kind == AST_PROGRAM)
|
||||
|
|
@ -99,3 +113,8 @@ void ast_print_node(t_ast_node self)
|
|||
return (ast_print_node_word(self));
|
||||
printf("Unknown ast->kind: %#04x\n", self->kind);
|
||||
}
|
||||
|
||||
void ast_print_node(t_ast_node self)
|
||||
{
|
||||
ast_print_block1(self);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue