diff options
-rw-r--r-- | asm/lexer.c | 13 | ||||
-rw-r--r-- | asm/lexer.h | 1 | ||||
-rw-r--r-- | todo.org | 4 |
3 files changed, 15 insertions, 3 deletions
diff --git a/asm/lexer.c b/asm/lexer.c index 0a8a97e..01c2e5d 100644 --- a/asm/lexer.c +++ b/asm/lexer.c @@ -24,6 +24,8 @@ const char *token_type_as_cstr(token_type_t type) { switch (type) { + case TOKEN_STAR: + return "STAR"; case TOKEN_LITERAL_NUMBER: return "LITERAL_NUMBER"; case TOKEN_LITERAL_CHAR: @@ -124,7 +126,7 @@ char uppercase(char c) bool is_symbol(char c) { - return isalpha(c) || c == '-' || c == '_' || c == '.'; + return isalpha(c) || c == '-' || c == '_' || c == '.' || c == ':'; } bool is_valid_hex_char(char c) @@ -431,6 +433,15 @@ lerr_t tokenise_buffer(buffer_t *buffer, token_stream_t *tokens_ptr) ++buffer->used; is_token = false; } + else if (c == '*') + { + t = (token_t){.type = TOKEN_STAR, + .column = column, + .str = malloc(1), + .str_size = 1}; + t.str[0] = '\0'; + ++buffer->used; + } else if (isdigit(c) || (space_left(buffer) > 1 && c == '-' && isdigit(buffer->data[buffer->used + 1]))) t = tokenise_number_literal(buffer, &column); diff --git a/asm/lexer.h b/asm/lexer.h index 6b17b04..2d747bc 100644 --- a/asm/lexer.h +++ b/asm/lexer.h @@ -17,6 +17,7 @@ typedef enum TokenType { + TOKEN_STAR, TOKEN_LITERAL_NUMBER, TOKEN_LITERAL_CHAR, TOKEN_NOOP, @@ -2,14 +2,14 @@ #+author: Aryadev Chavali #+date: 2023-11-02 -* TODO Write a label/jump system :ASM: +* WIP Write a label/jump system :ASM: Essentially a user should be able to write arbitrary labels (maybe through ~label x~ or ~x:~ syntax) which can be referred to by ~jump~. It'll purely be on the assembler side as a processing step, where the emitted bytecode purely refers to absolute addresses; the VM should just be dealing with absolute addresses here. -* TODO Allow relative addresses in jumps :ASM: +* WIP Allow relative addresses in jumps :ASM: As requested, a special syntax for relative address jumps. Sometimes it's a bit nicer than a label. * TODO Calling and returning control flow :VM: :ASM: |