lang: ast: implement s_terminator in block parser for all symbols
This commit is contained in:
@@ -38,7 +38,7 @@ static struct token_parse_result parse_else(
|
|||||||
return PARSE_RESULT(IVY_OK, PARSE_REPEAT_TOKEN);
|
return PARSE_RESULT(IVY_OK, PARSE_REPEAT_TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct token_parse_result parse_bang(
|
static struct token_parse_result parse_symbol(
|
||||||
struct ivy_parser *ctx, struct ivy_token *tok)
|
struct ivy_parser *ctx, struct ivy_token *tok)
|
||||||
{
|
{
|
||||||
struct block_parser_state *state
|
struct block_parser_state *state
|
||||||
@@ -47,12 +47,12 @@ static struct token_parse_result parse_bang(
|
|||||||
struct ivy_ast_block_node *node
|
struct ivy_ast_block_node *node
|
||||||
= (struct ivy_ast_block_node *)(state->s_base.s_node);
|
= (struct ivy_ast_block_node *)(state->s_base.s_node);
|
||||||
|
|
||||||
if (state->s_terminator != IVY_SYM_BANG) {
|
if (state->s_terminator == tok->t_symbol) {
|
||||||
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
parser_pop_state(ctx, STATE_ADD_NODE_TO_PARENT);
|
parser_pop_state(ctx, STATE_ADD_NODE_TO_PARENT);
|
||||||
return PARSE_RESULT(IVY_OK, PARSE_REPEAT_TOKEN);
|
return PARSE_RESULT(IVY_OK, PARSE_REPEAT_TOKEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct token_parse_result parse_expr_begin(
|
static struct token_parse_result parse_expr_begin(
|
||||||
@@ -107,7 +107,7 @@ struct ast_node_type block_node_ops = {
|
|||||||
KW_PARSER(ELSE, parse_else),
|
KW_PARSER(ELSE, parse_else),
|
||||||
},
|
},
|
||||||
.n_symbol_parsers = {
|
.n_symbol_parsers = {
|
||||||
SYM_PARSER(BANG, parse_bang),
|
SYM_PARSER_FALLBACK(parse_symbol),
|
||||||
},
|
},
|
||||||
.n_expr_parser = {
|
.n_expr_parser = {
|
||||||
.expr_begin = parse_expr_begin,
|
.expr_begin = parse_expr_begin,
|
||||||
|
|||||||
Reference in New Issue
Block a user