update: normed lots of stuff

This commit is contained in:
maix0 2024-09-19 17:35:57 +02:00
parent 978636b6ef
commit 50a2f3d4be
118 changed files with 1145 additions and 1330 deletions

View file

@ -6,11 +6,10 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/02 16:37:28 by rparodi #+# #+# */
/* Updated: 2024/09/15 20:14:14 by maiboyer ### ########.fr */
/* Updated: 2024/09/19 16:46:39 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "app/node.h"
#include "ast/_from_node.h"
#include "ast/ast.h"
#include "gmr/symbols.h"
@ -20,7 +19,7 @@
#include "parser/api.h"
#include <stdio.h>
t_error build_sym_heredoc_redirect(t_parse_node self, t_const_str input, \
t_error build_sym_heredoc_redirect(t_node self, t_const_str input, \
t_ast_node *out)
{
t_ast_node ret;

View file

@ -6,17 +6,18 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/17 13:04:32 by maiboyer #+# #+# */
/* Updated: 2024/09/02 16:39:08 by rparodi ### ########.fr */
/* Updated: 2024/09/19 16:47:11 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "app/node.h"
#include "parser/inner/ptypes.h"
#include "parser/inner/node.h"
#include "ast/ast.h"
#include "gmr/symbols.h"
#include "me/types.h"
#include <stdio.h>
t_error _build_not_finished(t_parse_node self, t_const_str i, t_ast_node *out)
t_error _build_not_finished(t_node self, t_const_str i, t_ast_node *out)
{
(void)(self);
(void)(out);

View file

@ -22,7 +22,7 @@
#include "parser/api.h"
#include <stdio.h>
t_error check_error_ternary(t_parse_node self, t_ast_node *out)
t_error check_error_ternary(t_node self, t_ast_node *out)
{
if (out == NULL)
return (ERROR);
@ -34,7 +34,7 @@ t_error check_error_ternary(t_parse_node self, t_ast_node *out)
}
t_error build_sym_arithmetic_ternary_expression(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_usize i;
@ -63,7 +63,7 @@ t_error build_sym_arithmetic_ternary_expression(\
}
t_error build_sym_arithmetic_unary_expression(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
@ -84,7 +84,7 @@ t_error build_sym_arithmetic_unary_expression(\
}
t_error arithmetic_choice(\
t_parse_node self, t_const_str input, t_ast_node *out, t_usize i)
t_node self, t_const_str input, t_ast_node *out, t_usize i)
{
if (ts_node_field_id_for_child(self, i) \
== sym_arithmetic_binary_expression)
@ -108,7 +108,7 @@ t_error arithmetic_choice(\
}
t_error build_sym_arithmetic_expansion(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_usize i;
t_ast_node ret;

View file

@ -22,7 +22,7 @@
#include "parser/api.h"
#include <stdio.h>
t_ast_arithmetic_operator _parse_operator(t_parse_node self)
t_ast_arithmetic_operator _parse_operator(t_node self)
{
t_symbol symbol;
@ -47,7 +47,7 @@ t_ast_arithmetic_operator _parse_operator(t_parse_node self)
}
t_error build_sym_arithmetic_binary_expression(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_usize i;
t_ast_node ret;
@ -77,7 +77,7 @@ t_error build_sym_arithmetic_binary_expression(\
}
t_error build_sym_arithmetic_literal(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_usize i;
t_ast_node ret;
@ -95,7 +95,7 @@ t_error build_sym_arithmetic_literal(\
}
t_error build_sym_arithmetic_parenthesized_expression( \
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
if (out == NULL)
return (ERROR);
@ -105,7 +105,7 @@ t_error build_sym_arithmetic_parenthesized_expression( \
}
t_error build_sym_arithmetic_postfix_expression(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;

View file

@ -38,7 +38,7 @@ t_vec_ast *_append_scripting(\
}
t_error build_sym_for_statement(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_ast_node tmp;
@ -84,12 +84,12 @@ t_error build_sym_for_statement(\
/*
t_error build_sym_while_statement(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_ast_node tmp;
t_usize i;
t_parse_node child;
t_node child;
t_ast_terminator_kind term;
if (out == NULL || ts_node_symbol(self) != sym_while_statement)
@ -140,7 +140,7 @@ t_error build_sym_while_statement(\
/*
t_error build_sym_do_group(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_ast_node tmp;

View file

@ -48,7 +48,7 @@ void ast_set_term(t_ast_node *node, t_ast_terminator_kind term)
}
t_error build_sym_if_statement(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
(void)(self);
(void)(input);
@ -56,7 +56,7 @@ t_error build_sym_if_statement(\
return (ERROR);
}
/*
t_parse_node child;
t_node child;
t_ast_node ret;
t_ast_node tmp;
t_usize i;
@ -102,7 +102,7 @@ t_error build_sym_if_statement(\
*/
t_error build_sym_elif_clause(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
(void)(self);
(void)(input);
@ -113,7 +113,7 @@ t_error build_sym_elif_clause(\
t_ast_node ret;
t_ast_node tmp;
t_usize i;
t_parse_node child;
t_node child;
(void)(out);
(void)(input);
@ -147,7 +147,7 @@ t_error build_sym_elif_clause(\
*/
t_error build_sym_else_clause(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
(void)(self);
(void)(input);
@ -158,7 +158,7 @@ t_error build_sym_else_clause(\
t_ast_node ret;
t_ast_node tmp;
t_usize i;
t_parse_node child;
t_node child;
(void)(out);
(void)(input);

View file

@ -21,7 +21,7 @@
#include <stdio.h>
t_error build_sym_negated_command(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
@ -41,7 +41,7 @@ t_error build_sym_negated_command(\
}
t_error build_sym_pipeline(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_ast_node t[2];
@ -70,7 +70,7 @@ t_error build_sym_pipeline(\
return (*out = ret, NO_ERROR);
}
t_error build_sym_comment(t_parse_node self, t_const_str input, t_ast_node *out)
t_error build_sym_comment(t_node self, t_const_str input, t_ast_node *out)
{
(void)(out);
(void)(input);
@ -84,10 +84,10 @@ t_error build_sym_comment(t_parse_node self, t_const_str input, t_ast_node *out)
}
t_error build_sym_variable_assignment(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_parse_node temp_ast;
t_node temp_ast;
(void)(self);
(void)(input);

View file

@ -32,7 +32,7 @@
*/
t_error build_sym_compound_statement(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_ast_node tmp;
@ -65,7 +65,7 @@ ret->data.program.body.len - 1], _select_term(ts_node_child(self, i)));
}
*/
t_error build_sym_program(t_parse_node self, t_const_str input, t_ast_node *out)
t_error build_sym_program(t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_usize i;
@ -90,7 +90,7 @@ t_error build_sym_program(t_parse_node self, t_const_str input, t_ast_node *out)
}
t_error build_sym_command_name(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
if (out == NULL)
return (ERROR);
@ -99,7 +99,7 @@ t_error build_sym_command_name(\
return (ast_from_node(ts_node_child(self, 0), input, out));
}
t_error build_sym_command(t_parse_node self, t_const_str input, t_ast_node *out)
t_error build_sym_command(t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_usize i;

View file

@ -23,12 +23,12 @@
#include <stdio.h>
void _build_sym_command_substitution_inner(\
t_parse_node self, t_const_str input, t_ast_node ret, t_usize i);
t_node self, t_const_str input, t_ast_node ret, t_usize i);
void _build_sym_expansion_inner(\
t_parse_node self, t_const_str input, t_ast_node ret, t_usize i);
t_node self, t_const_str input, t_ast_node ret, t_usize i);
t_error build_sym_regex(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
@ -42,7 +42,7 @@ t_error build_sym_regex(\
}
t_error build_sym_extglob_pattern(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
@ -56,7 +56,7 @@ t_error build_sym_extglob_pattern(\
}
t_error build_sym_expansion(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_ast_node tmp;
@ -84,7 +84,7 @@ t_error build_sym_expansion(\
}
t_error build_sym_simple_expansion(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_usize i;
@ -106,7 +106,7 @@ t_error build_sym_simple_expansion(\
}
t_error build_sym_command_substitution(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_ast_node tmp;

View file

@ -23,7 +23,7 @@
#include <stdio.h>
t_error build_sym_number(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
@ -41,7 +41,7 @@ t_error build_sym_number(\
}
t_error build_sym_file_descriptor(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;

View file

@ -20,12 +20,12 @@
#include "parser/api.h"
#include <stdio.h>
t_error ast_from_node(t_parse_node node, t_const_str input, t_ast_node *out);
t_error ast_from_node(t_node node, t_const_str input, t_ast_node *out);
// if (ts_node_symbol(node) == sym_while_statement)
// return (build_sym_while_statement(node, input, out));
t_error _from_node_inner3(\
t_parse_node node, t_const_str input, t_ast_node *out)
t_node node, t_const_str input, t_ast_node *out)
{
if (ts_node_symbol(node) == sym_pipeline)
return (build_sym_pipeline(node, input, out));
@ -59,7 +59,7 @@ t_error _from_node_inner3(\
// if (ts_node_symbol(node) == sym_if_statement)
// return (build_sym_if_statement(node, input, out));
t_error _from_node_inner2(\
t_parse_node node, t_const_str input, t_ast_node *out)
t_node node, t_const_str input, t_ast_node *out)
{
if (ts_node_symbol(node) == sym_extglob_pattern)
return (build_sym_extglob_pattern(node, input, out));
@ -85,7 +85,7 @@ t_error _from_node_inner2(\
// if (ts_node_symbol(node) == sym_else_clause)
// return (build_sym_else_clause(node, input, out));
t_error _from_node_inner(\
t_parse_node node, t_const_str input, t_ast_node *out)
t_node node, t_const_str input, t_ast_node *out)
{
if (ts_node_symbol(node) == sym_command)
return (build_sym_command(node, input, out));
@ -109,7 +109,7 @@ t_error _from_node_inner(\
// else if (ts_node_symbol(node) == sym_case_statement)
// return (build_sym_case_statement(node, input, out));
t_error ast_from_node(\
t_parse_node node, t_const_str input, t_ast_node *out)
t_node node, t_const_str input, t_ast_node *out)
{
if (out == NULL)
return (ERROR);

View file

@ -22,7 +22,7 @@
#include "parser/api.h"
#include <stdio.h>
t_ast_expansion_operator _extract_exp_fix(t_parse_node self)
t_ast_expansion_operator _extract_exp_fix(t_node self)
{
t_ast_expansion_operator kind;
t_symbol symbol;
@ -40,7 +40,7 @@ t_ast_expansion_operator _extract_exp_fix(t_parse_node self)
return (kind);
}
t_ast_expansion_operator _extract_exp_op(t_parse_node self)
t_ast_expansion_operator _extract_exp_op(t_node self)
{
t_ast_expansion_operator kind;
t_symbol symbol;
@ -95,7 +95,7 @@ void _add_negation(t_ast_node *node)
(*node)->data.variable_assignment.bang = true;
}
t_ast_redirection_kind _get_redirection_op(t_parse_node self)
t_ast_redirection_kind _get_redirection_op(t_node self)
{
t_symbol symbol;

View file

@ -68,13 +68,13 @@ void _append_redirection(t_ast_node node, t_ast_node redirection)
// if (symbol == anon_sym_SEMI_SEMI)
// return (AST_TERM_DOUBLE_SEMI);
// printf("unknown term symbol %d\n", symbol);
t_ast_terminator_kind _select_term(t_parse_node node)
t_ast_terminator_kind _select_term(t_node node)
{
(void)(node);
return (AST_TERM_NONE);
}
t_str _extract_str(t_parse_node self, t_const_str input)
t_str _extract_str(t_node self, t_const_str input)
{
t_usize start;
t_usize end;

View file

@ -18,7 +18,7 @@
#include "parser/api.h"
void _build_sym_expansion_inner(\
t_parse_node self, t_const_str input, t_ast_node ret, t_usize i)
t_node self, t_const_str input, t_ast_node ret, t_usize i)
{
if (ts_node_field_id_for_child(self, i) == field_len)
ret->data.expansion.len_operator = true;
@ -30,7 +30,7 @@ void _build_sym_expansion_inner(\
}
void _build_sym_command_substitution_inner(\
t_parse_node self, t_const_str input, t_ast_node ret, t_usize i)
t_node self, t_const_str input, t_ast_node ret, t_usize i)
{
(void)(input);
if (ret->data.command_substitution.body.len != 0)

View file

@ -17,7 +17,7 @@
#include "ast/_from_node.h"
static void _set_op_list(\
t_parse_node self, t_ast_node **output, t_ast_node ret, t_usize i)
t_node self, t_ast_node **output, t_ast_node ret, t_usize i)
{
t_symbol temp;
@ -29,7 +29,7 @@ static void _set_op_list(\
*output = &ret->data.list.right;
}
t_error build_sym_list(t_parse_node self, t_const_str input, t_ast_node *out)
t_error build_sym_list(t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_ast_node *output;
@ -55,7 +55,7 @@ t_error build_sym_list(t_parse_node self, t_const_str input, t_ast_node *out)
}
t_error build_sym_subshell(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_ast_node tmp;

View file

@ -23,7 +23,7 @@
#include <stdio.h>
t_error build_sym_file_redirect(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node n[2];
t_usize i;
@ -53,7 +53,7 @@ t_error build_sym_file_redirect(\
}
t_error build_sym_redirected_statement(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node n[3];
t_usize i;

View file

@ -23,7 +23,7 @@
#include <stdio.h>
t_error build_sym_function_definition(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
(void)(self);
(void)(input);
@ -64,7 +64,7 @@ t_error build_sym_function_definition(\
*/
t_error build_sym_case_statement(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
(void)(self);
(void)(input);
@ -106,7 +106,7 @@ t_error build_sym_case_statement(\
*/
t_error build_sym__case_item_last(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
(void)(self);
(void)(input);
@ -150,7 +150,7 @@ t_error build_sym__case_item_last(\
*/
t_error build_sym_case_item(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
(void)(self);
(void)(input);

View file

@ -21,7 +21,7 @@
#include <stdio.h>
t_error build_sym_word(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_str temp_str;
@ -43,7 +43,7 @@ t_error build_sym_word(\
}
t_error build_sym_string(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_usize i;
@ -72,7 +72,7 @@ t_error build_sym_string(\
}
t_error build_sym_concatenation(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_usize i;
@ -99,7 +99,7 @@ t_error build_sym_concatenation(\
}
t_error build_sym_string_content(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_str temp_str;
@ -117,7 +117,7 @@ t_error build_sym_string_content(\
}
t_error build_sym_raw_string(\
t_parse_node self, t_const_str input, t_ast_node *out)
t_node self, t_const_str input, t_ast_node *out)
{
t_ast_node ret;
t_ast_node temp;