40 lines
971 B
C
40 lines
971 B
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <sysexits.h>
|
|
#include "../includes/list.h"
|
|
#include "../includes/parser.h"
|
|
#include "../includes/futil.h"
|
|
#include "../includes/scanner.h"
|
|
|
|
int main(int argc, char* args[]) {
|
|
if (argc == 1) {
|
|
printf("Usage: assm <file1.asm>\n");
|
|
return EX_USAGE;
|
|
}
|
|
|
|
char* source_code;
|
|
size_t bytes_read;
|
|
|
|
if (!ReadAllString(args[1], &source_code, &bytes_read)) return EX_IOERR;
|
|
|
|
List* list = GenerateTokenList(source_code);
|
|
|
|
for(int i = 0; i < list->size; i++) {
|
|
Token* t = (Token*) list->content[i];
|
|
|
|
if (t->type == LineEnd) {
|
|
if (i - 1 >= 0 && ((Token*) list->content[i - 1])->type != LineEnd)
|
|
printf("\n");
|
|
|
|
continue;
|
|
}
|
|
|
|
printf("[%i] '%s' [%i] ", t->type, t->lexeme, t->token_class);
|
|
if (t->type == LABEL) printf("* ");
|
|
}
|
|
|
|
//ParseTokens(list);
|
|
|
|
free(source_code);
|
|
} |