lang: ast: fix parsing of unlabelled complex msg args
This commit is contained in:
@@ -739,6 +739,34 @@ not_complex_msg:
|
||||
|
||||
/* this is a generic parenthesis-enclosed sub-expression.
|
||||
* create a new sub-expr parser to handle it */
|
||||
|
||||
if (state->s_sub_type == EXPR_SUBTYPE_COMPLEX_MSG) {
|
||||
/* this is an unlabeled complex message arg */
|
||||
if (state->s_prev_token != IVY_SYM_COMMA
|
||||
&& state->s_prev_token != IVY_SYM_LEFT_PAREN) {
|
||||
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
||||
}
|
||||
|
||||
struct ivy_token *empty_label = malloc(sizeof *empty_label);
|
||||
if (!empty_label) {
|
||||
return PARSE_RESULT(IVY_ERR_NO_MEMORY, 0);
|
||||
}
|
||||
memset(empty_label, 0x0, sizeof *empty_label);
|
||||
empty_label->t_type = IVY_TOK_LABEL;
|
||||
|
||||
b_queue_push_back(&state->s_labels, &empty_label->t_entry);
|
||||
|
||||
struct expr_parser_state *arg_expr
|
||||
= (struct expr_parser_state *)parser_push_state(
|
||||
ctx, IVY_AST_EXPR, 0);
|
||||
expr_copy_terminators(state, arg_expr);
|
||||
expr_add_terminator(arg_expr, IVY_SYM_COMMA);
|
||||
arg_expr->s_sub_type = EXPR_SUBTYPE_COMPLEX_ARG;
|
||||
arg_expr->s_subexpr_depth = state->s_subexpr_depth + 1;
|
||||
|
||||
return PARSE_RESULT(IVY_OK, PARSE_REPEAT_TOKEN);
|
||||
}
|
||||
|
||||
struct expr_parser_state *sub_expr
|
||||
= (struct expr_parser_state *)parser_push_state(
|
||||
ctx, IVY_AST_EXPR, 0);
|
||||
|
||||
Reference in New Issue
Block a user