From 191fe5c6b8c6ea1c47be6ea110b76edc9790f568 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sat, 28 Oct 2023 18:19:33 +0100 Subject: Ignore comments (using semicolons) in lexer Easier to do it here than at the parser. --- asm/lexer.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'asm') diff --git a/asm/lexer.c b/asm/lexer.c index 556ac86..51a8ec6 100644 --- a/asm/lexer.c +++ b/asm/lexer.c @@ -110,6 +110,22 @@ token_stream_t tokenise_buffer(buffer_t *buffer) // Clean whitespace for (; space_left(buffer) > 0 && (isspace(c) || c == '\0'); ++buffer->used, c = buffer->data[buffer->used]) + { + ++column; + if (c == '\n') + { + column = 0; + ++line; + } + } + ++column; + is_token = false; + } + else if (c == ';') + { + // Stop lexing till next line + for (; space_left(buffer) > 0 && c != '\n'; + ++buffer->used, c = buffer->data[buffer->used]) continue; column = 0; ++line; -- cgit v1.2.3-13-gbd6f