lang: ast: add diag for do keyword in inline for-loop
This commit is contained in:
@@ -81,6 +81,27 @@ static struct token_parse_result parse_do(
|
||||
= parser_get_state(ctx, struct for_parser_state);
|
||||
|
||||
if (state->s_inline) {
|
||||
struct ivy_diag *diag = parser_push_diag(
|
||||
ctx, IVY_LANG_E_INCORRECT_INLINE_FOR_LOOP,
|
||||
IVY_LANG_MSG_DO_UNEXPECTED_IN_INLINE_FOR, tok);
|
||||
ivy_diag_push_msg(
|
||||
diag, IVY_LANG_MSG_PREVIOUS_EXPRESSION_IS_FOR_BODY);
|
||||
const struct ivy_char_cell *x = &state->s_body->n_end;
|
||||
const struct ivy_char_cell *z = &tok->t_end;
|
||||
|
||||
const struct ivy_diag_amendment a[] = {
|
||||
IVY_DIAG_ADD(x->c_row, x->c_col + 1, "."),
|
||||
};
|
||||
const size_t nr_a = sizeof a / sizeof a[0];
|
||||
|
||||
const struct ivy_diag_highlight hl[] = {
|
||||
IVY_DIAG_HL(
|
||||
HINT, x->c_row, x->c_col + 1, x->c_row,
|
||||
x->c_col + 1),
|
||||
};
|
||||
const size_t nr_hl = sizeof hl / sizeof hl[0];
|
||||
|
||||
ivy_diag_push_snippet(diag, x->c_row, z->c_row, a, nr_a, hl, nr_hl);
|
||||
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user