aboutsummaryrefslogtreecommitdiff
path: root/asm
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-28 18:19:33 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-28 18:19:33 +0100
commit191fe5c6b8c6ea1c47be6ea110b76edc9790f568 (patch)
tree9a80043755282af6c3609bb8197a225d59b4beeb /asm
parentd2429aa549c8f9082ba422b2e4705ff3e1d5683e (diff)
downloadovm-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')
-rw-r--r--asm/lexer.c16
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;