-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlexer.h
More file actions
55 lines (49 loc) · 1.51 KB
/
lexer.h
File metadata and controls
55 lines (49 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef LEXER_H
# define LEXER_H
typedef struct s_parse_buffer t_parse_buffer;
typedef enum e_token_type
{
TOKTYPE_EOF = -1,
TOKTYPE_PARSE_ERROR = 0,
TOKTYPE_NON_EXPANDABLE = 0xc101,
TOKTYPE_EXPANDABLE,
TOKTYPE_EXPANDABLE_QUOTED,
TOKTYPE_PIPE,
TOKTYPE_INPUT_REDIRECTION,
TOKTYPE_HEREDOCUMENT,
TOKTYPE_OUTPUT_REDIRECTION,
TOKTYPE_OUTPUT_APPENDING,
TOKTYPE_SEMICOLON,
TOKTYPE_NEWLINE,
TOKTYPE_SPACE,
} t_token_type;
typedef enum e_lexer_state
{
LEXSTAT_NORMAL = 0xd101,
LEXSTAT_SINGLE_QUOTED,
LEXSTAT_DOUBLE_QUOTED,
} t_lexer_state;
typedef struct s_token
{
char *text;
int length;
int max_length;
t_token_type type;
} t_token;
int lex_init_token(t_token *result);
int lex_expand_text_buf(t_token *result);
int lex_getc(t_parse_buffer *buf);
void lex_ungetc(t_parse_buffer *buf);
int lex_is_special_char(char ch);
int lex_read_word(t_parse_buffer *buf, t_token *result);
int lex_read_double_quoted(t_parse_buffer *buf, t_token *result);
int lex_read_single_quoted(t_parse_buffer *buf, t_token *result);
int lex_get_spaces(t_parse_buffer *buf, t_token *result, int ch);
int lex_get_symbols(t_parse_buffer *buf, t_token *result, int ch);
int lex_get_quoted(t_parse_buffer *buf, t_token *result, int ch);
int lex_get_token(t_parse_buffer *buf, t_token *result);
int lex_check_redirection_with_fd(t_parse_buffer *buf, t_token *result);
int lex_escaped(t_parse_buffer *buf, t_token *result);
int lex_get_eof(t_token *result, int ch);
void lex_get_lt_gt(t_parse_buffer *buf, t_token *result, int ch);
#endif