Lexer partially working

This commit is contained in:
2022-08-03 14:06:54 +01:00
parent 3cad70dddd
commit 1ff32fe101
17 changed files with 687 additions and 34 deletions

View File

@@ -6,29 +6,6 @@
#include <stdlib.h>
#include <string.h>
void printToken(Token* token) {
if (token->type == TOKEN_ERROR) {
printf("Error\t%d\t%.*s\n", token->line, token->length, token->lexeme);
return;
}
printf("\t%d\t%d\t", token->type, token->line);
if (token->type == TOKEN_IDENTIFIER || token->type == TOKEN_LITERAL_INTEGER || token->type == TOKEN_LITERAL_FLOAT || token->type == TOKEN_LITERAL_STRING) {
printf("%.*s\t", token->length, token->lexeme);
} else {
char* keyword = findKeywordByType(token->type);
if (keyword != NULL) {
printf("%s", keyword);
} else {
printf("-");
}
}
printf("\n");
}
//declare the singleton
Command command;