The Scanner has been refactored and some responsibilities were pulled from it. Confirmed working, the Parser still needs to be touched on however.

This commit is contained in:
2022-03-02 20:52:40 +00:00
parent 1b33468343
commit e20ccb8cfb
7 changed files with 238 additions and 177 deletions
+2 -8
View File
@@ -21,19 +21,13 @@ int main(int argc, char** argv) {
}
void Print(TokenList* list) {
char lexeme[100];
for(int i = 0; i < list->size; i++) {
if (list->tokens[i]->type == EndOF) {
printf("[Line %d] EOF\n", list->tokens[i]->line);\
return;
}
printf("[Line %d] ", list->tokens[i]->line);
for(int j = 0; j < list->tokens[i]->length; j++) {
printf("%c", list->tokens[i]->lexeme[j]);
}
printf("\n");
printf("[Line %d] %s\n", list->tokens[i]->line, list->tokens[i]->lexeme);
}
}
@@ -41,10 +35,10 @@ void RunFile(const char* path) {
printf("Running '%s'\n", path);
char* contents = GetFileContents(path);
TokenList* tokens = ScanTokens(contents);
free(contents);
Print(tokens);
DestroyTokenList(tokens);
free(contents);
}
char* GetFileContents(const char* path) {