lang: ast: implement parsing of static and dynamic package initialisers

This commit is contained in:
2024-12-07 20:56:57 +00:00
parent b87d152f07
commit 209c47da68
5 changed files with 518 additions and 7 deletions

View File

@@ -12,6 +12,13 @@ struct token_parse_result stmt_parse_for(
struct expr_parser_state *state
= parser_get_state(ctx, struct expr_parser_state);
if (state->s_terminator == IVY_KW_FOR) {
/* treat this as a statement terminator. */
struct token_parse_result result = expr_finalise_and_return(ctx, state);
result.r_flags |= PARSE_REPEAT_TOKEN;
return result;
}
if (state->s_sub_type == EXPR_SUBTYPE_KEYWORD_ARG) {
/* keyword messages have a higher precedence than inline
* conditionals, so treat this as a statement terminator. */
@@ -119,6 +126,13 @@ struct token_parse_result stmt_parse_if(
struct expr_parser_state *state
= parser_get_state(ctx, struct expr_parser_state);
if (state->s_terminator == IVY_KW_IF) {
/* treat this as a statement terminator. */
struct token_parse_result result = expr_finalise_and_return(ctx, state);
result.r_flags |= PARSE_REPEAT_TOKEN;
return result;
}
if (state->s_sub_type == EXPR_SUBTYPE_KEYWORD_ARG) {
/* keyword messages have a higher precedence than inline
* conditionals, so treat this as a statement terminator. */