lang: ast: re-factor condition group parser

this parser now only handles if-else statements, and uses the state init callback argument to receive any pre-existing inline expressions
This commit is contained in:
2024-12-04 21:02:55 +00:00
parent a34b9c3710
commit 0bb4a4284c
3 changed files with 27 additions and 52 deletions

View File

@@ -1,6 +1,5 @@
#include "../node.h"
#include "expr.h"
#include "../cond.h"
#include <blue/object/string.h>
#include <ivy/lang/lex.h>
@@ -35,13 +34,12 @@ struct token_parse_result stmt_parse_if(
parser_pop_state(ctx, 0);
}
struct cond_group_parser_state *cond
= (struct cond_group_parser_state *)parser_push_state(
ctx, IVY_AST_COND_GROUP, 0);
/* if expr is NULL, this is an if-then-else-end statement,
* otherwise, this is an expr-if-else-expr. */
cond->s_prev_node = expr;
struct cond_group_parser_state *cond
= (struct cond_group_parser_state *)parser_push_state(
ctx, IVY_AST_COND_GROUP, (uintptr_t)expr);
return PARSE_RESULT(IVY_OK, PARSE_REPEAT_TOKEN);
}