MiniDevil As beautiful as a shell
tokenizer_utils.c File Reference

Tokenizer helpers: detects operators, whitespace or word boundaries. More...

#include "token.h"
+ Include dependency graph for tokenizer_utils.c:

Detailed Description

Tokenizer helpers: detects operators, whitespace or word boundaries.

Definition in file tokenizer_utils.c.

Functions

int is_operator (char c)
 Check if a character is a shell operator. More...
 
int is_whitespace (char c)
 Check if a character is whitespace. More...
 
int is_word_end (char c)
 Check if a character ends a word token. More...
 
t_token_type get_operator_token_type (char *str, int *len)
 Determine operator token type and its length in characters. More...
 

Function Documentation

◆ is_operator()

int is_operator ( char  c)

Check if a character is a shell operator.

Parameters
cCharacter to test
Returns
1 if operator and 0 otherwise

Definition at line 21 of file tokenizer_utils.c.

Referenced by extract_unquoted(), is_word_end(), process_word_token(), and tokenize().

+ Here is the caller graph for this function:

◆ is_whitespace()

int is_whitespace ( char  c)

Check if a character is whitespace.

Parameters
cCharacter to test
Returns
1 if whitespace and 0 otherwise

Definition at line 32 of file tokenizer_utils.c.

Referenced by extract_unquoted(), is_word_end(), process_word_token(), and tokenize().

+ Here is the caller graph for this function:

◆ is_word_end()

int is_word_end ( char  c)

Check if a character ends a word token.

Parameters
cCharacter to test
Returns
1 if word ending and 0 otherwise

Definition at line 43 of file tokenizer_utils.c.

References is_operator(), and is_whitespace().

+ Here is the call graph for this function:

◆ get_operator_token_type()

t_token_type get_operator_token_type ( char *  str,
int *  len 
)

Determine operator token type and its length in characters.

Parameters
strInput at the operator position
lenOperator length (1 or 2)
Returns
Type of token for the operator

Definition at line 63 of file tokenizer_utils.c.

References TOKEN_APPEND, TOKEN_HEREDOC, TOKEN_PIPE, TOKEN_REDIR_IN, TOKEN_REDIR_OUT, and TOKEN_WORD.

Referenced by process_operator_token().

+ Here is the caller graph for this function:

Go to the source code of this file.