aboutsummaryrefslogtreecommitdiff
path: root/asm/parser.h
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-11-29 15:42:58 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-11-29 15:43:41 +0000
commit48d304056aeffbc172fa86ca1fedc418b4b213ff (patch)
tree3254c2d8a25858ff179eb45705aebe08efba6662 /asm/parser.h
parent4cee61fc9e196de6b19249b7fecc8905541a0495 (diff)
downloadovm-48d304056aeffbc172fa86ca1fedc418b4b213ff.tar.gz
ovm-48d304056aeffbc172fa86ca1fedc418b4b213ff.tar.bz2
ovm-48d304056aeffbc172fa86ca1fedc418b4b213ff.zip
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.
Diffstat (limited to 'asm/parser.h')
-rw-r--r--asm/parser.h13
1 files changed, 6 insertions, 7 deletions
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);