MiniDevil As beautiful as a shell
parser_grammar_error.c File Reference

Error reporting (maps syntax errors to user messages) More...

#include "parser.h"
#include "libft.h"
+ Include dependency graph for parser_grammar_error.c:

Detailed Description

Error reporting (maps syntax errors to user messages)

Definition in file parser_grammar_error.c.

Functions

static const char * get_error_msg (t_syntax_error err)
 Convert an error code to the corresponding message. More...
 
int print_syntax_error (t_syntax_error err)
 Print an error message to STDERR. More...
 
int is_redirection (t_token_type type)
 Check if a token type is a redirection operator. More...
 

Function Documentation

◆ get_error_msg()

static const char* get_error_msg ( t_syntax_error  err)
static

Convert an error code to the corresponding message.

Parameters
errError code
Returns
Static error message string or NULL if none were found

Definition at line 22 of file parser_grammar_error.c.

References ERR_EMPTY_INPUT, ERR_PIPE_DOUBLE, ERR_PIPE_END, ERR_PIPE_NO_CMD, ERR_PIPE_START, ERR_REDIR_AFTER_PIPE, and ERR_REDIR_NO_FILE.

Referenced by print_syntax_error().

+ Here is the caller graph for this function:

◆ print_syntax_error()

int print_syntax_error ( t_syntax_error  err)

Print an error message to STDERR.

Parameters
errError code
Returns
-1 always (value that will be return by callers)

Definition at line 44 of file parser_grammar_error.c.

References ERR_NONE, and get_error_msg().

Referenced by validate_empty(), validate_pipe_position(), and validate_redir_syntax().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_redirection()

int is_redirection ( t_token_type  type)

Check if a token type is a redirection operator.

Parameters
typeToken type to check
Returns
1 if redirection and 0 if not

Definition at line 62 of file parser_grammar_error.c.

References TOKEN_APPEND, TOKEN_HEREDOC, TOKEN_REDIR_IN, and TOKEN_REDIR_OUT.

Referenced by parse_command(), and validate_redir_syntax().

+ Here is the caller graph for this function:

Go to the source code of this file.