From 48d304056aeffbc172fa86ca1fedc418b4b213ff Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 29 Nov 2023 15:42:58 +0000 Subject: Refactored presult_t to include a stream pointer So when a presult_t is constructed it holds an index to where it was constructed in terms of the token stream. This will be useful when implementing an error checker in the preprocessing or result parsing stages. --- asm/parser.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'asm/parser.h') diff --git a/asm/parser.h b/asm/parser.h index c727eae..cef73b9 100644 --- a/asm/parser.h +++ b/asm/parser.h @@ -40,9 +40,9 @@ typedef enum const char *perr_as_cstr(perr_t); -// TODO: Refactor parser.c typedef struct { + size_t stream_index; inst_t instruction; s_word address; struct PLabel @@ -60,12 +60,11 @@ typedef struct } type; } presult_t; -// TODO: Implement these -presult_t presult_label(const char *, size_t, s_word); -presult_t presult_label_ref(inst_t, const char *, size_t); -presult_t presult_instruction(inst_t); -presult_t presult_relative(inst_t, s_word); -presult_t presult_global(const char *, size_t, s_word); +presult_t presult_label(size_t, const char *, size_t, s_word); +presult_t presult_label_ref(size_t, inst_t, const char *, size_t); +presult_t presult_instruction(size_t, inst_t); +presult_t presult_relative(size_t, inst_t, s_word); +presult_t presult_global(size_t, const char *, size_t, s_word); void presult_free(presult_t); void presults_free(presult_t *, size_t); -- cgit v1.2.3-13-gbd6f