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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user