Adding the litteral finish and the parentesized_expression \!
This commit is contained in:
parent
5402ec152a
commit
f4ccb91db4
2 changed files with 17 additions and 15 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/06/14 17:46:58 by maiboyer #+# #+# */
|
/* Created: 2024/06/14 17:46:58 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/07/21 17:46:08 by rparodi ### ########.fr */
|
/* Updated: 2024/07/22 12:43:06 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ sym_while_statement
|
||||||
sym_word
|
sym_word
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
@ -625,11 +624,11 @@ t_error build_sym_command_substitution(t_parse_node self, t_const_str input, t_a
|
||||||
|
|
||||||
/* FUNCTION DONE*/
|
/* FUNCTION DONE*/
|
||||||
t_error build_sym_arithmetic_binary_expression(t_parse_node self, t_const_str input, t_ast_node *out);
|
t_error build_sym_arithmetic_binary_expression(t_parse_node self, t_const_str input, t_ast_node *out);
|
||||||
|
t_error build_sym_arithmetic_literal(t_parse_node self, t_const_str input, t_ast_node *out);
|
||||||
|
|
||||||
/* FUNCTION THAT ARE NOT DONE */
|
/* FUNCTION THAT ARE NOT DONE */
|
||||||
|
|
||||||
// TODO: This is your homework raph
|
// TODO: This is your homework raph
|
||||||
t_error build_sym_arithmetic_literal(t_parse_node self, t_const_str input, t_ast_node *out);
|
|
||||||
t_error build_sym_arithmetic_parenthesized_expression(t_parse_node self, t_const_str input, t_ast_node *out);
|
t_error build_sym_arithmetic_parenthesized_expression(t_parse_node self, t_const_str input, t_ast_node *out);
|
||||||
t_error build_sym_arithmetic_postfix_expression(t_parse_node self, t_const_str input, t_ast_node *out);
|
t_error build_sym_arithmetic_postfix_expression(t_parse_node self, t_const_str input, t_ast_node *out);
|
||||||
t_error build_sym_arithmetic_ternary_expression(t_parse_node self, t_const_str input, t_ast_node *out);
|
t_error build_sym_arithmetic_ternary_expression(t_parse_node self, t_const_str input, t_ast_node *out);
|
||||||
|
|
@ -672,6 +671,7 @@ t_error build_sym_arithmetic_binary_expression(t_parse_node self, t_const_str in
|
||||||
return (*out = ret, NO_ERROR);
|
return (*out = ret, NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RAPH
|
||||||
t_error build_sym_arithmetic_literal(t_parse_node self, t_const_str input, t_ast_node *out)
|
t_error build_sym_arithmetic_literal(t_parse_node self, t_const_str input, t_ast_node *out)
|
||||||
{
|
{
|
||||||
t_usize i;
|
t_usize i;
|
||||||
|
|
@ -683,21 +683,23 @@ t_error build_sym_arithmetic_literal(t_parse_node self, t_const_str input, t_ast
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
i = 0;
|
i = 0;
|
||||||
ret = ast_alloc(AST_ARITHMETIC_LITTERAL);
|
ret = ast_alloc(AST_ARITHMETIC_LITTERAL);
|
||||||
while (i < ts_node_child_count(self))
|
if (ast_from_node(ts_node_child(self, i), input, &ret->data.arithmetic_literal.value))
|
||||||
{
|
return (ERROR);
|
||||||
if (ts_node_field_id_for_child(self, i) == field_lhs)
|
|
||||||
if (ast_from_node(ts_node_child(self, i), input, &ret->data.arithmetic_binary.lhs))
|
|
||||||
return (ERROR);
|
|
||||||
if (ts_node_field_id_for_child(self, i) == field_op)
|
|
||||||
ret->data.arithmetic_binary.op = _parse_operator(ts_node_child(self, i));
|
|
||||||
if (ts_node_field_id_for_child(self, i) == field_rhs)
|
|
||||||
if (ast_from_node(ts_node_child(self, i), input, &ret->data.arithmetic_binary.rhs))
|
|
||||||
return (ERROR);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return (*out = ret, NO_ERROR);
|
return (*out = ret, NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t_error build_sym_arithmetic_parenthesized_expression(t_parse_node self, t_const_str input, t_ast_node *out)
|
||||||
|
{
|
||||||
|
t_usize i;
|
||||||
|
t_ast_node ret;
|
||||||
|
|
||||||
|
if (out == NULL)
|
||||||
|
return (ERROR);
|
||||||
|
if (ts_node_symbol(self) != sym_arithmetic_parenthesized_expression)
|
||||||
|
return (ERROR);
|
||||||
|
return (ast_from_node(ts_node_child(self, 1), input, out));
|
||||||
|
}
|
||||||
|
|
||||||
t_error build_sym_command_substitution(t_parse_node self, t_const_str input, t_ast_node *out)
|
t_error build_sym_command_substitution(t_parse_node self, t_const_str input, t_ast_node *out)
|
||||||
{
|
{
|
||||||
t_ast_node ret;
|
t_ast_node ret;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue