Updated the scanner to parse registers, assembly keywords and identifiers.
This commit is contained in:
+5
-22
@@ -6,6 +6,7 @@
|
||||
#include "../includes/lexer.h"
|
||||
#include "../includes/parser.h"
|
||||
#include "../includes/futil.h"
|
||||
#include "../includes/scanner.h"
|
||||
|
||||
List* get_strings(const char*);
|
||||
|
||||
@@ -20,30 +21,12 @@ int main(int argc, char* args[]) {
|
||||
|
||||
if (!ReadAllString(args[1], &source_code, &bytes_read)) return EX_IOERR;
|
||||
|
||||
char* token = strtok(source_code, "\n");
|
||||
int line_number = 1;
|
||||
List* list = GenerateTokenList(source_code);
|
||||
|
||||
while(token != NULL) {
|
||||
for(int i = 0; i < list->size; i++) {
|
||||
Token* t = (Token*) list->content[i];
|
||||
|
||||
List* tokens = GetTokensFromLine(token);
|
||||
|
||||
if (line_number == 1 || line_number == 2) {
|
||||
ParseTokens(tokens);
|
||||
}
|
||||
|
||||
for (int i = 0; i < tokens->size; i++) {
|
||||
Token* t = (Token*) tokens->content[i];
|
||||
|
||||
printf("Token Type: '%d' Value: '%s' (%d)\n", t->type, t->value, line_number);
|
||||
|
||||
if (t->type <= ORG) free(t->value);
|
||||
}
|
||||
|
||||
DestroyList(tokens);
|
||||
|
||||
token = strtok(NULL, "\n");
|
||||
|
||||
line_number++;
|
||||
printf("[%i] '%s'\n", t->type, t->value);
|
||||
}
|
||||
|
||||
free(source_code);
|
||||
|
||||
Reference in New Issue
Block a user