aboutsummaryrefslogtreecommitdiff
path: root/src/parse/parse.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-08-25 00:40:03 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-08-25 00:40:03 -0400
commitaed80436a0a5eb12d9cace916167b0f7bd433589 (patch)
treec546a7f10621864ac697711b6f66a428cdaeb00b /src/parse/parse.h
parentb378f7359a6b8bd2e47bafdba496d115825adcd7 (diff)
Splitting out parser more.
Diffstat (limited to 'src/parse/parse.h')
-rw-r--r--src/parse/parse.h85
1 files changed, 72 insertions, 13 deletions
diff --git a/src/parse/parse.h b/src/parse/parse.h
index 24e173a5..1e8c979f 100644
--- a/src/parse/parse.h
+++ b/src/parse/parse.h
@@ -2,20 +2,79 @@
// Parsing logic
-#include <setjmp.h>
-#include <stdint.h>
-
#include "../ast.h"
-#include "../stdlib/files.h"
-
-#define SPACES_PER_INDENT 4
+#include "context.h"
-typedef struct {
- file_t *file;
- jmp_buf *on_err;
- int64_t next_lambda_id;
-} parse_ctx_t;
-
-ast_t *parse_file(const char *path, jmp_buf *on_err);
ast_t *parse(const char *str);
ast_t *parse_expression(const char *str);
+
+ast_e match_binary_operator(const char **pos);
+ast_t *parse_comprehension_suffix(parse_ctx_t *ctx, ast_t *expr);
+ast_t *parse_field_suffix(parse_ctx_t *ctx, ast_t *lhs);
+ast_t *parse_fncall_suffix(parse_ctx_t *ctx, ast_t *fn);
+ast_t *parse_index_suffix(parse_ctx_t *ctx, ast_t *lhs);
+ast_t *parse_method_call_suffix(parse_ctx_t *ctx, ast_t *self);
+ast_t *parse_non_optional_suffix(parse_ctx_t *ctx, ast_t *lhs);
+ast_t *parse_optional_conditional_suffix(parse_ctx_t *ctx, ast_t *stmt);
+ast_t *parse_optional_suffix(parse_ctx_t *ctx, ast_t *lhs);
+arg_ast_t *parse_args(parse_ctx_t *ctx, const char **pos);
+type_ast_t *parse_list_type(parse_ctx_t *ctx, const char *pos);
+type_ast_t *parse_func_type(parse_ctx_t *ctx, const char *pos);
+type_ast_t *parse_non_optional_type(parse_ctx_t *ctx, const char *pos);
+type_ast_t *parse_pointer_type(parse_ctx_t *ctx, const char *pos);
+type_ast_t *parse_set_type(parse_ctx_t *ctx, const char *pos);
+type_ast_t *parse_table_type(parse_ctx_t *ctx, const char *pos);
+type_ast_t *parse_type(parse_ctx_t *ctx, const char *pos);
+type_ast_t *parse_type_name(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_list(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_assignment(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_block(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_bool(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_convert_def(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_declaration(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_defer(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_do(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_doctest(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_assert(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_enum_def(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_expr(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_extended_expr(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_extern(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_for(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_func_def(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_heap_alloc(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_if(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_inline_c(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_int(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_lambda(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_lang_def(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_extend(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_namespace(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_negative(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_not(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_none(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_num(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_parens(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_pass(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_path(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_reduction(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_repeat(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_return(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_set(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_skip(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_stack_reference(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_statement(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_stop(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_struct_def(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_table(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_term(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_term_no_suffix(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_text(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_update(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_use(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_var(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_when(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_while(parse_ctx_t *ctx, const char *pos);
+ast_t *parse_deserialize(parse_ctx_t *ctx, const char *pos);
+ast_list_t *_parse_text_helper(parse_ctx_t *ctx, const char **out_pos, char open_quote, char close_quote,
+ char open_interp, bool allow_escapes);