diff options
Diffstat (limited to 'source/lexer/lexer.c')
| -rw-r--r-- | source/lexer/lexer.c | 74 |
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 @@ | |||
| 1 | internal b32 | ||
| 2 | is_alpha(u8 point) | ||
| 3 | { | ||
| 4 | return ((point >= 'a' && point <= 'z') || | ||
| 5 | (point >= 'A' && point <= 'Z') || | ||
| 6 | (point == '_')); | ||
| 7 | } | ||
| 8 | |||
| 9 | internal b32 | ||
| 10 | is_digit(u8 point) | ||
| 11 | { | ||
| 12 | return (point >= '0' && point <= '9'); | ||
| 13 | } | ||
| 14 | |||
| 15 | internal b32 | ||
| 16 | is_alpha_num(u8 point) | ||
| 17 | { | ||
| 18 | return (is_alpha(point) || is_digit(point)); | ||
| 19 | } | ||
| 20 | |||
| 21 | internal b32 | ||
| 22 | is_whitespace(u8 point) | ||
| 23 | { | ||
| 24 | return (point == '\n' || point == '\r' || | ||
| 25 | point == ' ' || point == '\t'); | ||
| 26 | } | ||
| 27 | |||
| 28 | internal b32 | ||
| 29 | is_delimiter(u8 point) | ||
| 30 | { | ||
| 31 | |||
| 32 | return (point == ','); | ||
| 33 | |||
| 34 | } | ||
| 35 | |||
| 1 | internal token * | 36 | internal token * |
| 2 | tokenize_csv(string8 buffer) | 37 | tokenize_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 | } |
