aboutsummaryrefslogtreecommitdiff
path: root/asm/parser.h
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-11-29 15:43:53 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-11-29 15:43:53 +0000
commit16dcc88a53467046de3f4cf8fb5249686e760eae (patch)
tree7566afc6aec0950a7d169079e7517287ff0e4b46 /asm/parser.h
parent48d304056aeffbc172fa86ca1fedc418b4b213ff (diff)
downloadovm-16dcc88a53467046de3f4cf8fb5249686e760eae.tar.gz
ovm-16dcc88a53467046de3f4cf8fb5249686e760eae.tar.bz2
ovm-16dcc88a53467046de3f4cf8fb5249686e760eae.zip
Refactored preprocessor to preprocess_(use|macro)_blocks and process_presults
We have distinct functions for the use blocks and the macro blocks, which each generate wholesale new token streams via `token_copy` so we don't run into weird errors around ownership of the internal strings of each token. Furthermore, process_presults now uses the stream index in each presult to report errors when stuff goes wrong.
Diffstat (limited to 'asm/parser.h')
-rw-r--r--asm/parser.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/asm/parser.h b/asm/parser.h
index cef73b9..7e2d1b7 100644
--- a/asm/parser.h
+++ b/asm/parser.h
@@ -86,12 +86,19 @@ typedef struct
block_t search_blocks(block_t *, size_t, char *, size_t);
+perr_t preprocess_use_blocks(token_stream_t *, token_stream_t *);
+perr_t preprocess_macro_blocks(token_stream_t *, token_stream_t *);
// Analyses then inlines corresponding tokens into stream directly
perr_t preprocessor(token_stream_t *);
-// Parses from the preprocessed stream
+
+// Parses the next "parse result" from stream
perr_t parse_next(token_stream_t *, presult_t *);
-// Deals with address building
-perr_t process_presults(presult_t *, size_t, prog_t **);
+// Constructs a program from the set of parse results (from repeatedly
+// calling parse_next)
+perr_t process_presults(presult_t *, size_t, size_t *, prog_t **);
+
+// Preprocesses, generates results then constructs a program all in
+// one routine (thing to call in most use cases).
perr_t parse_stream(token_stream_t *, prog_t **);
#endif