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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user