From 6e65349d705b691e9fec124e7d9bc8d0f5d80076 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Mon, 8 Sep 2025 16:01:02 +0100 Subject: [PATCH] lang: ast: fix some source formatting --- lang/ast/expr/arith.c | 4 +++- lang/ast/tuple.c | 26 +++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lang/ast/expr/arith.c b/lang/ast/expr/arith.c index 6d798f8..7368044 100644 --- a/lang/ast/expr/arith.c +++ b/lang/ast/expr/arith.c @@ -637,9 +637,11 @@ struct token_parse_result arith_parse_do( struct block_parser_state *block = (struct block_parser_state *)parser_push_state( ctx, IVY_AST_BLOCK, 0); - /* set the sub-expression depth to be non-zero so the expression parser doesn't consume the expression separator. */ + /* set the sub-expression depth to be non-zero so the expression parser + * doesn't consume the expression separator. */ state->s_prev_token = IVY_KW_DO; + return PARSE_RESULT(IVY_OK, 0); } diff --git a/lang/ast/tuple.c b/lang/ast/tuple.c index 47dc422..2e01cbd 100644 --- a/lang/ast/tuple.c +++ b/lang/ast/tuple.c @@ -19,7 +19,8 @@ struct tuple_parser_state { static void finalise_tuple(struct tuple_parser_state *state) { - struct ivy_ast_tuple_node *tuple = (struct ivy_ast_tuple_node *)state->s_base.s_node; + struct ivy_ast_tuple_node *tuple + = (struct ivy_ast_tuple_node *)state->s_base.s_node; tuple->n_members = state->s_items; state->s_items = B_QUEUE_INIT; @@ -27,7 +28,8 @@ static void finalise_tuple(struct tuple_parser_state *state) struct token_parse_result parse_comma(struct ivy_parser *ctx, struct ivy_token *tok) { - struct tuple_parser_state *state = parser_get_state(ctx, struct tuple_parser_state); + struct tuple_parser_state *state + = parser_get_state(ctx, struct tuple_parser_state); if (state->s_prev != IVY_SYM_LEFT_PAREN && state->s_prev != IVY_SYM_COMMA) { /* token not expected at this time. */ return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); @@ -42,7 +44,9 @@ struct token_parse_result parse_comma(struct ivy_parser *ctx, struct ivy_token * state->s_prev_node = NULL; state->s_prev = IVY_SYM_COMMA; - struct expr_parser_state *expr = (struct expr_parser_state *)parser_push_state(ctx, IVY_AST_EXPR, 0); + struct expr_parser_state *expr + = (struct expr_parser_state *)parser_push_state( + ctx, IVY_AST_EXPR, 0); expr_add_terminator(expr, IVY_SYM_COMMA); expr_add_terminator(expr, IVY_SYM_RIGHT_PAREN); expr->s_subexpr_depth = 1; @@ -50,9 +54,11 @@ struct token_parse_result parse_comma(struct ivy_parser *ctx, struct ivy_token * return PARSE_RESULT(IVY_OK, 0); } -struct token_parse_result parse_right_paren(struct ivy_parser *ctx, struct ivy_token *tok) +struct token_parse_result parse_right_paren( + struct ivy_parser *ctx, struct ivy_token *tok) { - struct tuple_parser_state *state = parser_get_state(ctx, struct tuple_parser_state); + struct tuple_parser_state *state + = parser_get_state(ctx, struct tuple_parser_state); if (state->s_prev != IVY_SYM_COMMA) { /* token not expected at this time. */ return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); @@ -76,8 +82,7 @@ struct token_parse_result parse_right_paren(struct ivy_parser *ctx, struct ivy_t static enum ivy_status add_child( struct parser_state *parent, struct ivy_ast_node *child) { - struct tuple_parser_state *state - = (struct tuple_parser_state *)parent; + struct tuple_parser_state *state = (struct tuple_parser_state *)parent; if (state->s_prev_node) { return IVY_ERR_BAD_SYNTAX; @@ -99,7 +104,9 @@ static void init_state(struct ivy_parser *ctx, struct parser_state *sp, uintptr_ state->s_prev = IVY_SYM_COMMA; } - struct expr_parser_state *expr = (struct expr_parser_state *)parser_push_state(ctx, IVY_AST_EXPR, 0); + struct expr_parser_state *expr + = (struct expr_parser_state *)parser_push_state( + ctx, IVY_AST_EXPR, 0); expr_add_terminator(expr, IVY_SYM_COMMA); expr_add_terminator(expr, IVY_SYM_RIGHT_PAREN); expr->s_subexpr_depth = 1; @@ -112,7 +119,8 @@ static void collect_children( b_queue_iterator it = {0}; b_queue_foreach (&it, &tuple->n_members) { - struct ivy_ast_node *item = b_unbox(struct ivy_ast_node, it.entry, n_entry); + struct ivy_ast_node *item + = b_unbox(struct ivy_ast_node, it.entry, n_entry); ast_node_iterator_enqueue_node(iterator, node, item); } }