#ifndef _AST_NODE_H_ #define _AST_NODE_H_ #include #include #define ast_node_create(type_id, type_struct) \ ((type_struct *)ast_node_create_with_size(type_id, sizeof(type_struct))) struct parser_state; typedef enum ivy_status (*token_parse_function)( struct ivy_parser *, struct ivy_token *); struct ast_node_type { enum ivy_status (*n_add_child)( struct ivy_ast_node *, struct ivy_ast_node *); void (*n_print)(struct ivy_ast_node *); void (*n_init_state)(struct parser_state *); void (*n_collect_children)(struct ivy_ast_node *, struct ivy_ast_node_iterator *); size_t n_state_size; size_t n_node_size; token_parse_function n_token_parsers[IVY_TOK_TYPE_COUNT]; token_parse_function n_keyword_parsers[IVY_KW_TYPE_COUNT]; token_parse_function n_symbol_parsers[IVY_SYM_TYPE_COUNT]; }; extern const struct ast_node_type *get_ast_node_type(enum ivy_ast_node_type type); extern token_parse_function get_token_parser( struct ivy_ast_node *context, struct ivy_token *tok); extern struct ivy_ast_node *ast_node_create_with_size( enum ivy_ast_node_type type, size_t size); extern enum ivy_status ast_node_add_child( struct ivy_ast_node *parent, struct ivy_ast_node *child); #endif