aboutsummaryrefslogtreecommitdiff
path: root/asm/lexer.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-11-02 20:52:05 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-11-02 20:54:26 +0000
commit9afeed6d617da4841a031423286a0b3f3804f774 (patch)
tree2d853a933aba53c4a400a1099f5b9e8b317422d8 /asm/lexer.c
parentbc3f12909380bd7a6f2d6dc76691ec8439b88388 (diff)
downloadovm-9afeed6d617da4841a031423286a0b3f3804f774.tar.gz
ovm-9afeed6d617da4841a031423286a0b3f3804f774.tar.bz2
ovm-9afeed6d617da4841a031423286a0b3f3804f774.zip
Made separate tokens for JUMP_ABS and JUMP_STACK
Makes more sense, don't need to fiddle around with strings as much in the parser due to this!
Diffstat (limited to 'asm/lexer.c')
-rw-r--r--asm/lexer.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/asm/lexer.c b/asm/lexer.c
index 836dd08..73859c3 100644
--- a/asm/lexer.c
+++ b/asm/lexer.c
@@ -86,8 +86,10 @@ const char *token_type_as_cstr(token_type_t type)
return "MULT";
case TOKEN_PRINT:
return "PRINT";
- case TOKEN_JUMP:
- return "JUMP";
+ case TOKEN_JUMP_ABS:
+ return "JUMP_ABS";
+ case TOKEN_JUMP_STACK:
+ return "JUMP_STACK";
case TOKEN_JUMP_IF:
return "JUMP_IF";
case TOKEN_SYMBOL:
@@ -293,16 +295,21 @@ token_t tokenise_symbol(buffer_t *buffer, size_t *column)
offset = 5;
type = TOKEN_PRINT;
}
+ else if (sym_size >= 8 && strncmp(opcode, "JUMP.ABS", 8) == 0)
+ {
+ offset = 8;
+ type = TOKEN_JUMP_ABS;
+ }
+ else if (sym_size >= 10 && strncmp(opcode, "JUMP.STACK", 10) == 0)
+ {
+ offset = 10;
+ type = TOKEN_JUMP_STACK;
+ }
else if (sym_size >= 7 && strncmp(opcode, "JUMP.IF", 7) == 0)
{
offset = 7;
type = TOKEN_JUMP_IF;
}
- else if (sym_size >= 4 && strncmp(opcode, "JUMP", 4) == 0)
- {
- offset = 4;
- type = TOKEN_JUMP;
- }
else
is_opcode = false;