diff options
author | Marvin Borner | 2021-04-27 16:24:24 +0200 |
---|---|---|
committer | Marvin Borner | 2021-04-27 16:24:24 +0200 |
commit | 7c047df78502d53411fef09c6e39540d2b7e796a (patch) | |
tree | 00a72bb40f81e7294cb1dde776159ed219ee4967 /src/parser.c | |
parent | 60e7b5069d5936546356053f85008a5a02bb473a (diff) |
Fixed some overflows and enabled live parsing
Diffstat (limited to 'src/parser.c')
-rw-r--r-- | src/parser.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/parser.c b/src/parser.c index 2f16323..e998135 100644 --- a/src/parser.c +++ b/src/parser.c @@ -31,7 +31,7 @@ static void rom_add(u8 byte) static u32 toks_count(struct token *toks) { struct token *p = toks; - while (p && p->type) + while (p && p->type != END && p->type != UNKNOWN && p->type != NEWLINE) p++; return p - toks; } @@ -387,7 +387,11 @@ static u32 parse_line(struct context *ctx, char *str, u32 size) break; } - if (tok.type == UNKNOWN) { + if (tok.type == UNKNOWN) + break; + + if (tok.type == END) { + ctx->line++; break; } @@ -609,6 +613,7 @@ static u32 parse_line(struct context *ctx, char *str, u32 size) case NUM_END: case REGS_START: case REGS_END: + case END: warnings_add(ctx, "Got enum boundary"); break; default: @@ -645,11 +650,16 @@ u8 parse(char *buf, u32 size) u32 len = parse_line(&ctx, buf + i, size - i); i += len; ctx.column += len; + + if (buf[i] == '\0') + break; } if (warnings_exist()) { warnings_print(); return 0; + } else { + warnings_remove_marks(); } return 1; |