lang: ast: add stub parser functions

This commit is contained in:
2024-11-23 10:15:40 +00:00
parent 8219797cbb
commit 5c5a2d236c
3 changed files with 149 additions and 6 deletions

View File

@@ -2,8 +2,11 @@
#define IVY_LANG_AST_H_
#include <blue/core/queue.h>
#include <ivy/misc.h>
#include <ivy/status.h>
struct ivy_token;
struct ivy_parser;
enum ivy_ast_node_type {
IVY_AST_NONE = 0x00,
@@ -67,7 +70,7 @@ struct ivy_ast_unit_node {
struct ivy_ast_op_node {
struct ivy_ast_node n_base;
enum ivy_ast_op n_op;
struct ivy_ast_node *n_left; // NULL for unary operators.
struct ivy_ast_node *n_left; // NULL for unary operators.
struct ivy_ast_node *n_right;
};
@@ -111,13 +114,14 @@ struct ivy_ast_property_node {
struct ivy_token *n_ident;
/* one of either:
* a) a lambda. the lambda is executed to get the property value; or,
* b) a constant value. the constant is returned as the property value.
* c) NULL. the property is write-only.
* b) a constant value. the constant is returned as the property
* value. c) NULL. the property is write-only.
*/
struct ivy_ast_node *n_get;
/* one of either:
* a) a lambda. the lambda is executed with the provided value as a parameter to set the property value; or,
* b) NULL. the property is read-only.
* a) a lambda. the lambda is executed with the provided value as a
* parameter to set the property value; or, b) NULL. the property is
* read-only.
*/
struct ivy_ast_node *n_set;
};
@@ -220,4 +224,18 @@ struct ivy_ast_do_node {
b_queue n_members;
};
#endif
IVY_API enum ivy_status ivy_parser_create(struct ivy_parser **parser);
IVY_API void ivy_parser_destroy(struct ivy_parser *parser);
IVY_API enum ivy_status ivy_parser_get_status(struct ivy_parser *parser);
IVY_API void ivy_parser_push_token(struct ivy_parser *lex, struct ivy_token *tok);
IVY_API void ivy_ast_node_destroy(struct ivy_ast_node *node);
IVY_API const char *ivy_ast_node_type_to_string(enum ivy_ast_node_type v);
IVY_API const char *ivy_ast_op_to_string(enum ivy_ast_op v);
IVY_API const char *ivy_ast_msgh_recipient_type_to_string(
enum ivy_ast_msgh_recipient_type v);
#endif