Minishell
 
Loading...
Searching...
No Matches
Lexer structure

Core functionality of the lexer. More...

Data Structures

struct  s_lexer_state
 Structure used by lexer to efficiently have access to a bunch of variables. More...
 

Macros

#define MAX_TOKENS_LEX   1024
 

Functions

char ** init_lexer_state (t_garbage *garbage, t_lexer_state *lex_st, const char *line)
 Initialize the lexer structure.
 
char ** lexer (t_garbage *garbage, const char *line)
 Create tokens (small chunks) a line with the quotes and operators.
 
t_commandtokeniser (t_data *data, char **tokens)
 Creates a t_command structure that contains all the tokens Fills the command with the environment.
 
char * ft_substr_end_gb (t_garbage *garbage, char const *src, unsigned int start, size_t end)
 Allocate memory for a string and copy the content from src.
 
int is_operator_char (char c)
 Is |, < or >
 

Detailed Description

Core functionality of the lexer.

Functions to make a correct use of lexing and tokenisation.

Macro Definition Documentation

◆ MAX_TOKENS_LEX

#define MAX_TOKENS_LEX   1024

Function Documentation

◆ ft_substr_end_gb()

char * ft_substr_end_gb ( t_garbage * garbage,
char const * src,
unsigned int start,
size_t end )

Allocate memory for a string and copy the content from src.

Parameters
garbagegarbage structure
srcsource string
startstart index to copy from
endend index to copy to
Returns
char* pointer to the new string
Here is the call graph for this function:

◆ init_lexer_state()

char ** init_lexer_state ( t_garbage * garbage,
t_lexer_state * lex_st,
const char * line )

Initialize the lexer structure.

Fill the structure with zeros and init the line to search in and allocates the array to the garbage

Parameters
garbagegarbage structure
lex_stpointer to the lexer structure
lineline to verify
Here is the call graph for this function:

◆ is_operator_char()

int is_operator_char ( char c)

Is |, < or >

Parameters
ccharacter to check
Returns
int 1 if c is operator, 0 otherwise

◆ lexer()

char ** lexer ( t_garbage * garbage,
const char * line )

Create tokens (small chunks) a line with the quotes and operators.

Handle spaces, quotes (' and ') and shell operator (|, <, <<, >, >>). Return an array of tokens (strings), NULL terminated.

Parameters
garbagegarbage structure
lineline to tokenise
Returns
Array of strings
Here is the call graph for this function:

◆ tokeniser()

t_command * tokeniser ( t_data * data,
char ** tokens )

Creates a t_command structure that contains all the tokens Fills the command with the environment.

Parameters
datadata structure
tokenstokens
Returns
t_command* pointer if OK, NULL if it fails
Here is the call graph for this function: