diff options
Diffstat (limited to 'lexer.c')
| -rw-r--r-- | lexer.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -1,5 +1,4 @@ #include <stdlib.h> -#include <stdio.h> #include <string.h> #include "lexer.h" @@ -21,6 +20,8 @@ char* tttos(tokenType_t tokenType) { return "ERR"; case EOL: return "EOL"; + case INDENT: + return "INDENT"; case STRING: return "STRING"; case INT: @@ -53,7 +54,7 @@ char* tttos(tokenType_t tokenType) { } int advance_whitespace(char** linePointer) { int64_t a = (int64_t)linePointer; - while (**linePointer == ' ' || **linePointer == ' ') { + while (**linePointer == ' ') { (*linePointer)++; } return (int)((int64_t)linePointer - a); @@ -67,13 +68,11 @@ tokenSet_t lex_line(char* line) { while (1) { token_t t = lex_first_token(p); if (t.type == EOL) { - printf("eol\n"); break; } if (t.type == ERR) { exit(1); } - printf("good\n"); tokens[i] = t; i++; } @@ -89,7 +88,6 @@ token_t lex_first_token(char** content) { s[c] = **content; s[c+1] = '\0'; (*content)++; - printf("lexing: %c\n", s[c]); /* check if we need to parse a string or an int */ if (s[c] >= 65 && s[c] <= 90) { free(s); @@ -114,6 +112,10 @@ token_t lex_first_token(char** content) { free(s); return init_token(START_COMMENT, NULL); } + else if (strcmp(s, " ") == 0) { + free(s); + return init_token(INDENT, NULL); + } else if (strcmp(s, "|") == 0) { free(s); return init_token(JUSTIFICATION, NULL); @@ -155,7 +157,6 @@ token_t lex_first_token(char** content) { return init_token(BI_IMPLICATION, NULL); } else if (c <= m) { - printf("c: %d\n", c); c++; continue; } |
