MiniDevil As beautiful as a shell
parser.h
Go to the documentation of this file.
1 /* ************************************************************************** */
2 /* */
3 /* ::: :::::::: */
4 /* parser.h :+: :+: :+: */
5 /* +:+ +:+ +:+ */
6 /* By: baelgadi <baelgadi@student.42.fr> +#+ +:+ +#+ */
7 /* +#+#+#+#+#+ +#+ */
8 /* Created: 2025/12/07 22:17:12 by zotaj-di #+# #+# */
9 /* Updated: 2026/03/11 02:57:26 by baelgadi ### ########.fr */
10 /* */
11 /* ************************************************************************** */
12 
13 #ifndef PARSER_H
14 # define PARSER_H
15 
16 # include "structs.h"
17 
18 t_ast *parse(t_token *tokens);
19 
20 t_ast *parse_pipeline(t_token **tokens);
21 
22 t_ast *parse_command(t_token **tokens);
23 
25 
26 char **collect_args(t_token **tokens, int *argc);
27 
29 
31 
32 int validate_syntax(t_token *tokens);
33 
34 int count_word_tokens(t_token *tokens);
35 
37 
38 char *join_connected_delim(t_token **tokens, int *quoted);
39 
40 /* ────────────── B O N U S ──────────────── */
41 
44 int print_logic_error(t_token_type type);
45 
46 t_ast *parse_and_or(t_token **tokens);
47 
48 t_ast *parse_subshell(t_token **tokens);
49 
52 #endif
int print_syntax_error(t_syntax_error err)
Print an error message to STDERR.
char * join_connected_delim(t_token **tokens, int *quoted)
Join connected tokens in a single string.
int count_word_tokens(t_token *tokens)
Count consecutive word token groups.
Definition: parser_cmd.c:25
t_ast * parse_pipeline(t_token **tokens)
Parse a pipeline of commands connected by pipes.
t_ast * parse_simple_command(t_token **tokens)
Parse a simple command from consecutive word tokens.
Definition: parser_cmd.c:117
t_ast * parse(t_token *tokens)
Parse a token list into an AST.
Definition: parser.c:26
int is_redirection(t_token_type type)
Check if a token type is a redirection operator.
char ** collect_args(t_token **tokens, int *argc)
Collect consecutive word tokens into an arguments array.
Definition: parser_cmd.c:88
t_ast * reverse_redir_chain(t_ast *node)
Reverse a redirection chain for left to right execution order.
t_ast * parse_command(t_token **tokens)
Parse a command with all its redirections.
Definition: parser_redir.c:134
int validate_syntax(t_token *tokens)
Run all validation checks on a token list.
Central type definitions for mandatory part.
t_syntax_error
Syntax error codes (for parser)
Definition: structs.h:184
t_token_type
Token types produced by Lexer.
Definition: structs.h:24
AST node (union based ↑)
Definition: structs.h:151
Lexer token (singly linked list)
Definition: structs.h:71