lang: ast: implement control flags returned by parser functions
This commit is contained in:
@@ -10,20 +10,22 @@ struct unit_package_parser_state {
|
||||
int s_prev_token;
|
||||
};
|
||||
|
||||
static enum ivy_status parse_dot(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
static struct token_parse_result parse_dot(
|
||||
struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
{
|
||||
struct unit_package_parser_state *state
|
||||
= parser_get_state(ctx, struct unit_package_parser_state);
|
||||
|
||||
if (state->s_prev_token != IVY_TOK_IDENT) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
||||
}
|
||||
|
||||
state->s_prev_token = IVY_SYM_DOT;
|
||||
return IVY_OK;
|
||||
return PARSE_RESULT(IVY_OK, 0);
|
||||
}
|
||||
|
||||
static enum ivy_status parse_ident(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
static struct token_parse_result parse_ident(
|
||||
struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
{
|
||||
struct unit_package_parser_state *state
|
||||
= parser_get_state(ctx, struct unit_package_parser_state);
|
||||
@@ -32,26 +34,27 @@ static enum ivy_status parse_ident(struct ivy_parser *ctx, struct ivy_token *tok
|
||||
= (struct ivy_ast_unit_package_node *)(state->s_base.s_node);
|
||||
|
||||
if (state->s_prev_token == IVY_TOK_IDENT) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
||||
}
|
||||
|
||||
b_queue_push_back(&node->n_ident, &tok->t_entry);
|
||||
|
||||
state->s_prev_token = IVY_TOK_IDENT;
|
||||
return IVY_OK;
|
||||
return PARSE_RESULT(IVY_OK, 0);
|
||||
}
|
||||
|
||||
static enum ivy_status parse_linefeed(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
static struct token_parse_result parse_linefeed(
|
||||
struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
{
|
||||
struct unit_package_parser_state *state
|
||||
= parser_get_state(ctx, struct unit_package_parser_state);
|
||||
|
||||
if (state->s_prev_token != IVY_TOK_IDENT) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
||||
}
|
||||
|
||||
parser_pop_state(ctx, STATE_ADD_NODE_TO_PARENT);
|
||||
return IVY_OK;
|
||||
return PARSE_RESULT(IVY_OK, 0);
|
||||
}
|
||||
|
||||
static enum ivy_status add_child(
|
||||
|
||||
Reference in New Issue
Block a user