lang: ast: implement parsing of try-catch-finally statements

This commit is contained in:
2025-01-16 13:15:48 +00:00
parent 143d61e329
commit 46d244a28d
6 changed files with 352 additions and 10 deletions

View File

@@ -9,7 +9,8 @@ void expr_add_terminator(struct expr_parser_state *state, unsigned short tok)
}
}
void expr_copy_terminators(const struct expr_parser_state *src, struct expr_parser_state *dest)
void expr_copy_terminators(
const struct expr_parser_state *src, struct expr_parser_state *dest)
{
dest->s_nr_terminators = src->s_nr_terminators;
@@ -77,11 +78,14 @@ struct ast_node_type expr_node_ops = {
.n_keyword_parsers = {
/* statement keywords */
KW_PARSER(FOR, stmt_parse_for),
KW_PARSER(TRY, stmt_parse_try),
KW_PARSER(WHILE, stmt_parse_while),
KW_PARSER(MATCH, stmt_parse_match),
KW_PARSER(IF, stmt_parse_if),
KW_PARSER(THEN, stmt_parse_end),
KW_PARSER(ELSE, stmt_parse_end),
KW_PARSER(CATCH, stmt_parse_end),
KW_PARSER(FINALLY, stmt_parse_end),
KW_PARSER(END, stmt_parse_end),
/* operator/block keywords */