diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-28 18:19:33 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-28 18:19:33 +0100 |
commit | 191fe5c6b8c6ea1c47be6ea110b76edc9790f568 (patch) | |
tree | 9a80043755282af6c3609bb8197a225d59b4beeb /asm/lexer.c | |
parent | d2429aa549c8f9082ba422b2e4705ff3e1d5683e (diff) | |
download | ovm-191fe5c6b8c6ea1c47be6ea110b76edc9790f568.tar.gz ovm-191fe5c6b8c6ea1c47be6ea110b76edc9790f568.tar.bz2 ovm-191fe5c6b8c6ea1c47be6ea110b76edc9790f568.zip |
Ignore comments (using semicolons) in lexer
Easier to do it here than at the parser.
Diffstat (limited to 'asm/lexer.c')
-rw-r--r-- | asm/lexer.c | 16 |
1 files changed, 16 insertions, 0 deletions
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; |