aboutsummaryrefslogtreecommitdiff
path: root/asm/parser.h
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-28 18:20:15 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-28 18:21:09 +0100
commiteac8cbf1dab16ea3f2e066e142c6d6da39bdfea0 (patch)
tree2793221c4a6627b406a8506be70e9dca96e180d8 /asm/parser.h
parent191fe5c6b8c6ea1c47be6ea110b76edc9790f568 (diff)
downloadovm-eac8cbf1dab16ea3f2e066e142c6d6da39bdfea0.tar.gz
ovm-eac8cbf1dab16ea3f2e066e142c6d6da39bdfea0.tar.bz2
ovm-eac8cbf1dab16ea3f2e066e142c6d6da39bdfea0.zip
asm/parser supports all opcodes, introduced parse errors
Introduced some functions to parse differing types of opcodes. Use the same style of a.b.c... for namespacing or type specification for certain opcodes. Bit hacky and not tested, but does work. Parse errors can be reported with an exact location using the token column, line.
Diffstat (limited to 'asm/parser.h')
-rw-r--r--asm/parser.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/asm/parser.h b/asm/parser.h
index 09a11d4..9da1117 100644
--- a/asm/parser.h
+++ b/asm/parser.h
@@ -17,7 +17,20 @@
#include <vm/inst.h>
-inst_t parse_next_inst(token_stream_t *);
-inst_t *parse_stream(token_stream_t *, size_t *);
+typedef enum
+{
+ PERR_OK = 0,
+ PERR_INTEGER_OVERFLOW,
+ PERR_NOT_A_NUMBER,
+ PERR_EXPECTED_TYPE,
+ PERR_EXPECTED_SYMBOL,
+ PERR_EXPECTED_OPERAND,
+ PERR_UNKNOWN_OPERATOR,
+} perr_t;
+
+const char *perr_as_cstr(perr_t);
+
+perr_t parse_next_inst(token_stream_t *, inst_t *);
+perr_t parse_stream(token_stream_t *, inst_t **, size_t *);
#endif