minishell
Minishell Project for École 42
Loading...
Searching...
No Matches
parser.c File Reference

Functions for lexical analysis, tokenization and parsing. More...

#include "minishell.h"
Include dependency graph for parser.c:

Functions

bool check_pipe_syntax (t_lexer_list *lexer)
 Performs a pipe syntax check on the given list of lexems t_lexer_list *lexer.
 
t_lexer_listlexer (t_shell *shell)
 Lexical analysis and tokenization of the input string.
 
bool parser (t_shell *shell)
 Parses the input using the lexer.
 

Detailed Description

Functions for lexical analysis, tokenization and parsing.

Function Documentation

◆ check_pipe_syntax()

bool check_pipe_syntax ( t_lexer_list lexer)

Performs a pipe syntax check on the given list of lexems t_lexer_list *lexer.

Checks the lexer list for a syntax error with pipes, by checking if a valid token is encounterd after a PIPE token.

Parameters
lexerA pointer to the lexer list.
Returns
bool true if syntax is correct, otherwise false.

◆ lexer()

t_lexer_list * lexer ( t_shell shell)

Lexical analysis and tokenization of the input string.

Performs the lexical analysis and tokenization of the input string. First frees the previous 'rl_copy' if it exists, then creates a clean copy of the input string and removes leading/trailing whitespaces. Checks the syntax of the quotes. If syntax is incorrect, print message, set g_exit_code and return NULL. Calls tokenize() to tokenize the clean copy and returns the head of the returned lexer list.

Parameters
shellThe shell data structure (main data structure). @ return A pointer to the head of the lexer list if successful, otherwise NULL.

◆ parser()

bool parser ( t_shell shell)

Parses the input using the lexer.

Performs the parsing operation using the lexer. It first frees the existing lexer list if it exists. Then uses lexer() to generate a new list. If it failes to produce a new list, returns false. Else returns true.

Parameters
shellThe shell data structure (main data structure).
Returns
true if parsing is successful, false otherwise.