aboutsummaryrefslogtreecommitdiff
path: root/include/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/parser.h')
-rw-r--r--include/parser.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/include/parser.h b/include/parser.h
index 531d67d..b9fb3b7 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -8,6 +8,8 @@
#include "tokenizer.h"
#include "defs.h"
+#include <setjmp.h>
+
#define PARSER_OK 0
/* General error */
#define PARSER_ERR -1
@@ -25,6 +27,11 @@ struct ParserThreadData {
ScopedAllocator allocator;
};
+typedef enum {
+ ERROR_CONTEXT_NONE,
+ ERROR_CONTEXT_RHS_START
+} ErrorContext;
+
typedef struct {
Tokenizer tokenizer;
Buffer ast_objects;
@@ -32,6 +39,8 @@ typedef struct {
amal_compiler *compiler;
bool started;
TokenizerError error;
+ ErrorContext error_context;
+ jmp_buf parse_env;
} Parser;
CHECK_RESULT int parser_thread_data_init(ParserThreadData *self);
@@ -44,9 +53,13 @@ CHECK_RESULT int parser_init(Parser *self, amal_compiler *compiler, ScopedAlloca
/*
@buffer_name will be the path to the file when using parser_parse_file and when parsing a buffer
you can name the buffer anything you want to identify it.
+Should only be called once for a parser object.
*/
CHECK_RESULT int parser_parse_buffer(Parser *self, BufferView code_buffer, BufferView buffer_name);
-/* Parses a file and the dependencies that are included using @import */
+/*
+Parses a file and the dependencies that are included using @import.
+Should only be called once for a parser object.
+*/
CHECK_RESULT int parser_parse_file(Parser *self, BufferView filepath);
#endif