aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-03-03 14:54:07 +0100
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commit465c544d4a593a135c86390d61385cfbd2f93dd5 (patch)
treedf51caef09740a3e3e6eb1b79b61cf0d2913b680 /include
parentb3b0c807a75c4f854495b547d8e00a598979cbf6 (diff)
Use setjmp, longjmp instead of return_if_error to improve performance
Diffstat (limited to 'include')
-rw-r--r--include/ast.h2
-rw-r--r--include/parser.h15
2 files changed, 16 insertions, 1 deletions
diff --git a/include/ast.h b/include/ast.h
index 05bb6ee..29a0b64 100644
--- a/include/ast.h
+++ b/include/ast.h
@@ -85,6 +85,8 @@ struct Binop {
Ast lhs;
Ast rhs;
BinopType type;
+ /* Is the binop already ordered - no need to reorder it */
+ bool grouped;
};
Ast ast_none();
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