blob: c847c1d043f6e4f6701460a7739902057805662b (
plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
#include "lexer.h"
#include "parse/parse.h"
int len_is_not_sep(char *input)
{
int i;
i = -1;
while(input[++i])
{
if (lexer_sep(input[i]))
{
if (input[i + 1] == ' ')
while(input[++i] == ' ')
;
return(i);
}
if (input[i] == '\'' || input[i] == '"')
{
i = lexer_verif_entre_cote(input, i);
if (input[i] == ' ')
return(i + 1);
return(i);
}
if (input[i] == ' ')
{
while(input[++i] == ' ')
;
return (i);
}
}
return(i);
}
int check_input(char *input)
{
int i;
i = 0;
if (lexer_sep(input[i]))
{
while(input[i] == input[i + 1])
i++;
i += lexe_space(&input[i + 1]);
return (i + 1);
}
if (input[i] == 39 || input[i] == '"')
return(lexer_verif_entre_cote(input, i));
if (input[i] == ' ')
{
while(input[++i] == ' ')
;
return (i);
}
return(len_is_not_sep(&input[i]));
}
void check_input_out(char *input)
{
int i;
int j;
char *str;
i = 0;
while(input[i] != '\0')
{
j = 0;
j += len_is_not_sep(&input[i]);
if (j != 0)
{
str = malloc(sizeof(char) * j + 1);
ft_strlcpy(str, &input[i], j + 1);
printf("%s%d\n",str, j);
free(str);
}
i += j;
j = check_input(&input[i]);
str = malloc(sizeof(char) * j + 1);
ft_strlcpy(str, &input[i], j + 1);
printf("%s%d\n",str, j);
free(str);
i += j;
}
}
t_token *create_token_list(void)
{
t_token *lst_token;
if (!(lst_token = malloc(sizeof(t_token) * 1)))
return (NULL);
free(lst_token);
return (lst_token);
}
t_ftlst *lexer(char *input)
{
t_ftlst *lst;
if (!input)
return (0);
if(!(lst = malloc(sizeof(t_ftlst) * 1)))
return(NULL);
check_input_out(input);
free(lst);
return (0);
}
|