From 9cb8e4f83b49355610134b152df129b2f68ce9fe Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sat, 8 May 2021 12:22:25 -0400 Subject: Start implementing whole file lexing. This will eventually replace the per-line lexer. --- asmmon.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'asmmon.c') diff --git a/asmmon.c b/asmmon.c index 81edff2..75e331b 100644 --- a/asmmon.c +++ b/asmmon.c @@ -23,6 +23,9 @@ symbol *last_sym = 0; fixup *fixups = 0; fixup *last_fix = 0; +strln *first_strln = 0; +strln *last_strln = 0; + static char tstr[2048]; void viewmem(uint64_t address) { @@ -347,6 +350,30 @@ void list(uint16_t start, uint16_t end, uint8_t all, uint8_t ln, uint8_t addr, u } while (s != e && s); } +strln *make_strln(char *str, int blanks) { + strln *new_strln = malloc(sizeof(strln)); + + if (new_strln == NULL) { + return NULL; + } + + new_strln->next = NULL; + new_strln->prev = NULL; + new_strln->str = str; + new_strln->blanks = blanks; + + if (last_strln == NULL) { + first_strln = new_strln; + } else { + new_strln->prev = last_strln; + last_strln->next = new_strln; + } + + last_strln = new_strln; + + return new_strln; +} + int asmmon(const char *fn) { FILE *fp = NULL; FILE *fp2 = NULL; @@ -616,6 +643,11 @@ int asmmon(const char *fn) { default : break; } if (!is_valid) { + size_t len = strlen(lex_line); + char *tmp = malloc(len+1); + memcpy(tmp, lex_line, len); + tmp[len] = '\0'; + strln *dummy = make_strln(tmp, bline); address = lex(lex_line, address, bline, dbg); bline = 0; } -- cgit v1.2.3-13-gbd6f