MiniDevil
As beautiful as a shell
Redirection parsing: parses <, >, >>, << tokens & files.
More...
Include dependency graph for parser_redir.c:Redirection parsing: parses <, >, >>, << tokens & files.
Definition in file parser_redir.c.
Functions | |
| static t_node_type | get_redir_node_type (t_token_type type) |
| Convert a token type to the corresponding AST redirection node type. More... | |
| static t_ast * | parse_one_redirection (t_token **tokens, t_ast *cmd) |
| Parse a single redirection token and the following WORD (filename) More... | |
| 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. More... | |
| static t_ast * | get_command_node (t_ast *node) |
| Extract the innermost command from a redirection chain. More... | |
| t_ast * | parse_command (t_token **tokens) |
| Parse a command with all its redirections. More... | |
|
static |
Convert a token type to the corresponding AST redirection node type.
| type | Token type |
Definition at line 23 of file parser_redir.c.
References NODE_COMMAND, NODE_REDIR_APPEND, NODE_REDIR_HEREDOC, NODE_REDIR_IN, NODE_REDIR_OUT, TOKEN_APPEND, TOKEN_HEREDOC, TOKEN_REDIR_IN, and TOKEN_REDIR_OUT.
Referenced by parse_one_redirection().
Here is the caller graph for this function:Parse a single redirection token and the following WORD (filename)
| tokens | Pointer to current token pointer (advanced) |
| cmd | Command to wrap |
Definition at line 44 of file parser_redir.c.
References create_redir_node(), free_ast(), get_redir_node_type(), join_connected_delim(), t_token::next, TOKEN_WORD, and t_token::type.
Referenced by parse_command().
Here is the call graph for this function:
Here is the caller graph for this function:Collect trailing WORD tokens and merge them into a command's args.
Handles cases such as "cmd arg1 > out arg2" as it collects new_args, allocates a merged array and copies old + new args, then updates cmd->data.cmd.args and argc
| cmd | Command node to extend |
| tokens | Pointer to current token pointer |
Definition at line 80 of file parser_redir.c.
References t_cmd_node::argc, t_cmd_node::args, t_ast_data::cmd, collect_args(), and t_ast::data.
Referenced by parse_command().
Here is the call graph for this function:
Here is the caller graph for this function:Extract the innermost command from a redirection chain.
| node | Starting node of the chain |
Definition at line 115 of file parser_redir.c.
References t_redir_node::cmd, t_ast::data, NODE_REDIR_HEREDOC, NODE_REDIR_IN, t_ast_data::redir, and t_ast::type.
Referenced by parse_command().
Here is the caller graph for this function:Parse a command with all its redirections.
Parses a simple command and wraps it in redirection nodes as long as redirection tokens follow. After each redirection it collects any trailing word tokens and adds them to the command's args
| tokens | Pointer to current token pointer (advanced) |
Definition at line 134 of file parser_redir.c.
References collect_and_merge_remaining_args(), get_command_node(), is_redirection(), parse_one_redirection(), parse_simple_command(), and reverse_redir_chain().
Referenced by parse_pipeline().
Here is the call graph for this function:
Here is the caller graph for this function: