aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-08-11 19:33:23 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-08-11 19:34:23 +0300
commit3065334aec0f357c88eab144628a798db4a3e5ea (patch)
tree93e819215c6599103f28408c3b7afe8487b4685e /include
parent0bee8234a52c9399544364e8d26b124cb487ce7c (diff)
downloadek-3065334aec0f357c88eab144628a798db4a3e5ea.tar.gz
ek-3065334aec0f357c88eab144628a798db4a3e5ea.zip
parse struct continuation
+ Similar in idea to impl in Rust
Diffstat (limited to 'include')
-rw-r--r--include/ek/ast.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/include/ek/ast.h b/include/ek/ast.h
index 62a0901..59101ba 100644
--- a/include/ek/ast.h
+++ b/include/ek/ast.h
@@ -79,6 +79,8 @@ enum ast_kind {
AST_TRAIT_DEF,
/** Structure definition. */
AST_STRUCT_DEF,
+ /** Structure continuation, kind of like impl in Rust. */
+ AST_STRUCT_CONT_DEF,
/** If. */
AST_IF,
/** Block. E.g. \c {} */
@@ -372,7 +374,8 @@ static inline bool is_primitive(struct type *t)
#define gen_type(k, a, type, loc) gen_ast(k, a, NULL, NULL, NULL, type, NULL, \
-1, \
loc)
-#define gen_str2(k, s, a, b, loc) gen_ast(k, a, b, NULL, NULL, NULL, s, -1, loc)
+#define gen_str3(k, s, a, b, c, loc) gen_ast(k, a, b, c, NULL, NULL, s, -1, loc)
+#define gen_str2(k, s, a, b, loc) gen_str3(k, s, a, b, NULL, loc)
#define gen_str1(k, s, a, loc) gen_str2(k, s, a, NULL, loc)
#define gen_str(k, s, loc) gen_ast(k, NULL, NULL, NULL, NULL, NULL, s, -1, loc)
@@ -568,6 +571,13 @@ static inline bool is_primitive(struct type *t)
#define gen_struct(id, params, body, loc) \
gen_str2(AST_STRUCT_DEF, id, params, body, loc)
+#define struct_cont_id(x) return_s(x, AST_STRUCT_CONT_DEF)
+#define struct_cont_params(x) return_a0(x, AST_STRUCT_CONT_DEF)
+#define struct_cont_behav(x) return_t1(x, AST_STRUCT_CONT_DEF)
+#define struct_cont_body(x) return_a2(x, AST_STRUCT_CONT_DEF)
+#define gen_struct_cont(id, params, behav, body, loc) \
+ gen_ast(AST_STRUCT_CONT_DEF, params, body, NULL, NULL, behav, id, 0, loc)
+
#define val_id(x) return_s(x, AST_VAL)
#define val_val(x) return_a0(x, AST_VAL)
#define gen_val(id, val, loc) \