lang: ast: implement control flags returned by parser functions
This commit is contained in:
@@ -14,26 +14,27 @@ struct class_parser_state {
|
||||
int s_prev_token;
|
||||
};
|
||||
|
||||
static enum ivy_status parse_dollar(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
static struct token_parse_result parse_dollar(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= parser_get_state(ctx, struct class_parser_state);
|
||||
|
||||
if (state->s_current_area != AREA_BODY) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
||||
}
|
||||
|
||||
parser_push_state(ctx, IVY_AST_PROPERTY);
|
||||
return IVY_OK;
|
||||
return PARSE_RESULT(IVY_OK, 0);
|
||||
}
|
||||
|
||||
static enum ivy_status parse_plus(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
static struct token_parse_result parse_plus(
|
||||
struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= parser_get_state(ctx, struct class_parser_state);
|
||||
|
||||
if (state->s_current_area != AREA_BODY) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
||||
}
|
||||
|
||||
parser_push_state(ctx, IVY_AST_MSGH);
|
||||
@@ -42,16 +43,17 @@ static enum ivy_status parse_plus(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
= (struct ivy_ast_msgh_node *)msgh_state->s_node;
|
||||
msgh->n_recipient = IVY_AST_MSGH_CLASS;
|
||||
|
||||
return IVY_OK;
|
||||
return PARSE_RESULT(IVY_OK, 0);
|
||||
}
|
||||
|
||||
static enum ivy_status parse_hyphen(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
static struct token_parse_result parse_hyphen(
|
||||
struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= parser_get_state(ctx, struct class_parser_state);
|
||||
|
||||
if (state->s_current_area != AREA_BODY) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
||||
}
|
||||
|
||||
parser_push_state(ctx, IVY_AST_MSGH);
|
||||
@@ -60,10 +62,11 @@ static enum ivy_status parse_hyphen(struct ivy_parser *ctx, struct ivy_token *to
|
||||
= (struct ivy_ast_msgh_node *)msgh_state->s_node;
|
||||
msgh->n_recipient = IVY_AST_MSGH_OBJECT;
|
||||
|
||||
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 class_parser_state *state
|
||||
= parser_get_state(ctx, struct class_parser_state);
|
||||
@@ -72,19 +75,20 @@ static enum ivy_status parse_ident(struct ivy_parser *ctx, struct ivy_token *tok
|
||||
= (struct ivy_ast_class_node *)(state->s_base.s_node);
|
||||
|
||||
if (state->s_current_area != AREA_IDENT) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
||||
}
|
||||
|
||||
if (state->s_prev_token == IVY_TOK_IDENT) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
||||
}
|
||||
|
||||
node->n_ident = tok;
|
||||
state->s_prev_token = IVY_TOK_IDENT;
|
||||
return IVY_OK;
|
||||
return PARSE_RESULT(IVY_OK, 0);
|
||||
}
|
||||
|
||||
static enum ivy_status parse_end(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
static struct token_parse_result parse_end(
|
||||
struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
{
|
||||
struct class_parser_state *state
|
||||
= parser_get_state(ctx, struct class_parser_state);
|
||||
@@ -93,29 +97,30 @@ static enum ivy_status parse_end(struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
= (struct ivy_ast_class_node *)(state->s_base.s_node);
|
||||
|
||||
if (state->s_current_area == AREA_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 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 class_parser_state *state
|
||||
= parser_get_state(ctx, struct class_parser_state);
|
||||
|
||||
if (state->s_current_area != AREA_IDENT) {
|
||||
return IVY_OK;
|
||||
return PARSE_RESULT(IVY_OK, 0);
|
||||
}
|
||||
|
||||
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_TOK_LINEFEED;
|
||||
state->s_current_area = AREA_BODY;
|
||||
return IVY_OK;
|
||||
return PARSE_RESULT(IVY_OK, 0);
|
||||
}
|
||||
|
||||
static enum ivy_status add_child(
|
||||
|
||||
Reference in New Issue
Block a user