54 lines
1.0 KiB
C
54 lines
1.0 KiB
C
#include <stdio.h>
|
|
#include "../includes/futil.h"
|
|
#include "../includes/tokenizer.h"
|
|
|
|
int main(int argc, char** argv) {
|
|
char* file;
|
|
size_t count;
|
|
|
|
//gcc -o test src/main.c src/futil.c src/dictionary.c src/tokenizer.c src/token.c src/array.c -g
|
|
|
|
if (argc <= 1) {
|
|
printf("Usage: assm <file.asm>\n");
|
|
|
|
return 2;
|
|
}
|
|
|
|
if (!ReadAllString(argv[1], &file, &count)) {
|
|
printf("Failed to read file '%s'.", argv[1]);
|
|
|
|
return 1;
|
|
}
|
|
|
|
Dictionary* variables = DictionaryCreate();
|
|
|
|
Array* tokens = Tokenize(file, &variables);
|
|
|
|
if (tokens->Size == 0) {
|
|
printf("No tokens\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
char* buffer;
|
|
|
|
for(int i = 0; i < tokens->Size; i++) {
|
|
Token* token = tokens->Items[i];
|
|
|
|
if (token->Type == LineEnd) {
|
|
printf("\n");
|
|
|
|
continue;
|
|
}
|
|
|
|
buffer = TokenStringify(token);
|
|
|
|
if (buffer) {
|
|
printf("%s ", buffer);
|
|
|
|
free(buffer);
|
|
}
|
|
}
|
|
|
|
printf("\n");
|
|
} |