aboutsummaryrefslogtreecommitdiff
path: root/asm/lexer.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-26 10:22:35 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-26 10:22:53 +0100
commitb1523655614f91e765b674b4b7db6adf79ff403b (patch)
tree2a5db95bc8e8f68c5e7fa5b315bb08b798e481e9 /asm/lexer.c
parent3200e97324f10b2840817fffafbe4368dc3cb219 (diff)
downloadovm-b1523655614f91e765b674b4b7db6adf79ff403b.tar.gz
ovm-b1523655614f91e765b674b4b7db6adf79ff403b.tar.bz2
ovm-b1523655614f91e765b674b4b7db6adf79ff403b.zip
Lexer forces uppercase for symbols
Diffstat (limited to 'asm/lexer.c')
-rw-r--r--asm/lexer.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/asm/lexer.c b/asm/lexer.c
index 7c3f7da..149d717 100644
--- a/asm/lexer.c
+++ b/asm/lexer.c
@@ -43,13 +43,21 @@ bool is_symbol(char c)
return isalpha(c) || c == '-' || c == '_' || c == '.';
}
+char uppercase(char c)
+{
+ if (c >= 'a' && c <= 'z')
+ return (c - 'a') + 'A';
+ return c;
+}
+
token_t tokenise_symbol(buffer_t *buffer)
{
token_t token = {.type = TOKEN_SYMBOL, .str_size = 0};
for (; token.str_size < space_left(buffer) &&
is_symbol(buffer->data[buffer->used + token.str_size]);
++token.str_size)
- continue;
+ buffer->data[buffer->used + token.str_size] =
+ uppercase(buffer->data[buffer->used + token.str_size]);
token.str = calloc(token.str_size + 1, 1);
memcpy(token.str, buffer->data + buffer->used, token.str_size);
token.str[token.str_size] = '\0';