52 *tokens = (*tokens)->
next;
90 merged = malloc(
sizeof(
char *) * (cmd->
data.
cmd.
argc + new_argc + 1));
93 ft_free_strarray(new_args);
97 while (++i < cmd->data.cmd.argc)
100 while (++i < new_argc)
139 if (!tokens || !*tokens)
t_ast * create_redir_node(t_node_type type, char *file, t_ast *cmd, int quoted)
Create a redirection AST node.
AST node creation and destruction prototypes.
void free_ast(t_ast *node)
Recursively free an entire AST tree.
Parser entry point & sub parser prototypes.
t_ast * parse_simple_command(t_token **tokens)
Parse a simple command from consecutive word tokens.
char ** collect_args(t_token **tokens, int *argc)
Collect consecutive word tokens into an arguments array.
int is_redirection(t_token_type type)
Check if a token type is a redirection operator.
static t_ast * get_command_node(t_ast *node)
Extract the innermost command from a redirection chain.
static void collect_and_merge_remaining_args(t_ast *cmd, t_token **tokens)
Collect trailing WORD tokens and merge them into a command's args.
static t_ast * parse_one_redirection(t_token **tokens, t_ast *cmd)
Parse a single redirection token and the following WORD (filename)
t_ast * parse_command(t_token **tokens)
Parse a command with all its redirections.
static t_node_type get_redir_node_type(t_token_type type)
Convert a token type to the corresponding AST redirection node type.
char * join_connected_delim(t_token **tokens, int *quoted)
Join connected tokens in a single string.
t_ast * reverse_redir_chain(t_ast *node)
Reverse a redirection chain for left to right execution order.
t_token_type
Token types produced by Lexer.
t_node_type
AST node types.
t_ast_data data
cmd, redir or binary data
t_node_type type
To determine which union member to pick.
char ** args
NULL terminated args array.
int argc
Number of arguments.
struct s_ast * cmd
Command subtree.
Lexer token (singly linked list)
t_token_type type
Token type (word, pipe, redir)
struct s_token * next
Next token.