summaryrefslogtreecommitdiff
path: root/source/lexer/lexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/lexer/lexer.c')
-rw-r--r--source/lexer/lexer.c74
1 files changed, 72 insertions, 2 deletions
diff --git a/source/lexer/lexer.c b/source/lexer/lexer.c
index 8182c5a..1c7ab38 100644
--- a/source/lexer/lexer.c
+++ b/source/lexer/lexer.c
@@ -1,10 +1,80 @@
1internal b32
2is_alpha(u8 point)
3{
4 return ((point >= 'a' && point <= 'z') ||
5 (point >= 'A' && point <= 'Z') ||
6 (point == '_'));
7}
8
9internal b32
10is_digit(u8 point)
11{
12 return (point >= '0' && point <= '9');
13}
14
15internal b32
16is_alpha_num(u8 point)
17{
18 return (is_alpha(point) || is_digit(point));
19}
20
21internal b32
22is_whitespace(u8 point)
23{
24 return (point == '\n' || point == '\r' ||
25 point == ' ' || point == '\t');
26}
27
28internal b32
29is_delimiter(u8 point)
30{
31
32 return (point == ',');
33
34}
35
1internal token * 36internal token *
2tokenize_csv(string8 buffer) 37tokenize_csv(string8 buffer)
3{ 38{
39 i32 count = 0;
40 string8 **tokens = PushArray(arena, string8 *, buffer.size / 10);
41
4 if(buffer.size < 0) return NULL; 42 if(buffer.size < 0) return NULL;
5 for(i32 index = 0; 43 for(i32 index = 0;
6 buffer.data[index] != '\0' 44 buffer.data[index] != '\0';
7 ;) 45 ++index)
46 {
47 string8 tokens = {0};
48
49 u8 point = buffer.data[index];
50 if(is_whitespace(point)) continue;
51
52 u8 *start = &buffer.data;
53
54 if(is_delimiter(point))
55 {
56
57
58 }
59
60 u8 *end = start - 1;
61
62 unused(start);
63 unused(end);
64
65 switch (point)
66 {
67
68 default:
69 {
70 printf("point: %c\n", point);
71 count++;
72 }
73 }
74
75 }
76
77 printf("%d", count);
8 78
9 return NULL; 79 return NULL;
10} 80}