#include "ctx.h" #include bool parse_package_id(struct ivy_parser *parser, struct ivy_ast_node **out) { if (!parse_keyword(parser, IVY_KW_PACKAGE)) { parse_trace(NULL, "expected `package` before package statement"); return false; } struct ivy_ast_unit_package_node *unit_pkg = create_node(IVY_AST_UNIT_PACKAGE); struct ivy_token *tok = NULL; if (!parse_word(parser, &tok)) { parse_trace(NULL, "expected word after `package` keyword"); return false; } fx_queue_push_back(&unit_pkg->n_ident, &tok->t_entry); while (1) { if (parse_linefeed(parser)) { break; } if (!parse_symbol(parser, IVY_SYM_DOT)) { parse_trace( NULL, "expected linefeed or `.` after package " "identifier word"); destroy_node(unit_pkg); return false; } if (!parse_word(parser, &tok)) { parse_trace( NULL, "expected word after `package` keyword"); destroy_node(unit_pkg); return false; } fx_queue_push_back(&unit_pkg->n_ident, &tok->t_entry); } *out = generic_node(unit_pkg); return true; }