lang: ast: update arith parser to set ast node bounds
This commit is contained in:
@@ -62,6 +62,7 @@ enum ivy_status arith_push_operand(
|
|||||||
= (struct ivy_ast_ident_node *)ast_node_create(
|
= (struct ivy_ast_ident_node *)ast_node_create(
|
||||||
IVY_AST_IDENT);
|
IVY_AST_IDENT);
|
||||||
v->n_content = tok;
|
v->n_content = tok;
|
||||||
|
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
|
||||||
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
|
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -69,6 +70,7 @@ enum ivy_status arith_push_operand(
|
|||||||
struct ivy_ast_int_node *v
|
struct ivy_ast_int_node *v
|
||||||
= (struct ivy_ast_int_node *)ast_node_create(IVY_AST_INT);
|
= (struct ivy_ast_int_node *)ast_node_create(IVY_AST_INT);
|
||||||
v->n_value = tok;
|
v->n_value = tok;
|
||||||
|
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
|
||||||
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
|
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -77,6 +79,7 @@ enum ivy_status arith_push_operand(
|
|||||||
= (struct ivy_ast_double_node *)ast_node_create(
|
= (struct ivy_ast_double_node *)ast_node_create(
|
||||||
IVY_AST_DOUBLE);
|
IVY_AST_DOUBLE);
|
||||||
v->n_value = tok;
|
v->n_value = tok;
|
||||||
|
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
|
||||||
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
|
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -84,6 +87,7 @@ enum ivy_status arith_push_operand(
|
|||||||
struct ivy_ast_atom_node *v
|
struct ivy_ast_atom_node *v
|
||||||
= (struct ivy_ast_atom_node *)ast_node_create(IVY_AST_ATOM);
|
= (struct ivy_ast_atom_node *)ast_node_create(IVY_AST_ATOM);
|
||||||
v->n_content = tok;
|
v->n_content = tok;
|
||||||
|
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
|
||||||
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
|
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -92,6 +96,7 @@ enum ivy_status arith_push_operand(
|
|||||||
= (struct ivy_ast_string_node *)ast_node_create(
|
= (struct ivy_ast_string_node *)ast_node_create(
|
||||||
IVY_AST_STRING);
|
IVY_AST_STRING);
|
||||||
v->n_value = tok;
|
v->n_value = tok;
|
||||||
|
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
|
||||||
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
|
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -101,6 +106,7 @@ enum ivy_status arith_push_operand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ivy_ast_node *v = ast_node_create(IVY_AST_DISCARD);
|
struct ivy_ast_node *v = ast_node_create(IVY_AST_DISCARD);
|
||||||
|
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
|
||||||
b_queue_push_back(&state->s_output_queue, &v->n_entry);
|
b_queue_push_back(&state->s_output_queue, &v->n_entry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -141,6 +147,7 @@ static struct ivy_ast_selector_node *unary_selector_from_token(struct ivy_token
|
|||||||
{
|
{
|
||||||
struct ivy_ast_selector_node *sel
|
struct ivy_ast_selector_node *sel
|
||||||
= (struct ivy_ast_selector_node *)ast_node_create(IVY_AST_SELECTOR);
|
= (struct ivy_ast_selector_node *)ast_node_create(IVY_AST_SELECTOR);
|
||||||
|
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)sel, tok);
|
||||||
sel->n_msg_name = tok;
|
sel->n_msg_name = tok;
|
||||||
return sel;
|
return sel;
|
||||||
}
|
}
|
||||||
@@ -156,12 +163,15 @@ static struct ivy_ast_node *create_operator_node_from_token(struct ivy_token *to
|
|||||||
struct ivy_ast_msg_node *new_msg_node
|
struct ivy_ast_msg_node *new_msg_node
|
||||||
= (struct ivy_ast_msg_node *)ast_node_create(IVY_AST_MSG);
|
= (struct ivy_ast_msg_node *)ast_node_create(IVY_AST_MSG);
|
||||||
new_msg_node->n_sel = unary_selector_from_token(tok);
|
new_msg_node->n_sel = unary_selector_from_token(tok);
|
||||||
|
ivy_ast_node_set_bounds_from_token(
|
||||||
|
(struct ivy_ast_node *)new_msg_node, tok);
|
||||||
return (struct ivy_ast_node *)new_msg_node;
|
return (struct ivy_ast_node *)new_msg_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ivy_ast_op_node *new_op_node
|
struct ivy_ast_op_node *new_op_node
|
||||||
= (struct ivy_ast_op_node *)ast_node_create(IVY_AST_OP);
|
= (struct ivy_ast_op_node *)ast_node_create(IVY_AST_OP);
|
||||||
new_op_node->n_op = op;
|
new_op_node->n_op = op;
|
||||||
|
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)new_op_node, tok);
|
||||||
return (struct ivy_ast_node *)new_op_node;
|
return (struct ivy_ast_node *)new_op_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,11 +379,18 @@ enum ivy_status expr_finalise_arith(
|
|||||||
op = op_node->n_op;
|
op = op_node->n_op;
|
||||||
tmp = b_queue_pop_back(&q);
|
tmp = b_queue_pop_back(&q);
|
||||||
op_node->n_right = b_unbox(struct ivy_ast_node, tmp, n_entry);
|
op_node->n_right = b_unbox(struct ivy_ast_node, tmp, n_entry);
|
||||||
|
op_node->n_right->n_parent = (struct ivy_ast_node *)op_node;
|
||||||
|
ivy_ast_node_extend_bounds_recursive(
|
||||||
|
(struct ivy_ast_node *)op_node, (struct ivy_ast_node *)tmp);
|
||||||
|
|
||||||
if (op->op_arity == IVY_OP_BINARY) {
|
if (op->op_arity == IVY_OP_BINARY) {
|
||||||
tmp = b_queue_pop_back(&q);
|
tmp = b_queue_pop_back(&q);
|
||||||
op_node->n_left
|
op_node->n_left
|
||||||
= b_unbox(struct ivy_ast_node, tmp, n_entry);
|
= b_unbox(struct ivy_ast_node, tmp, n_entry);
|
||||||
|
op_node->n_left->n_parent = (struct ivy_ast_node *)op_node;
|
||||||
|
ivy_ast_node_extend_bounds_recursive(
|
||||||
|
(struct ivy_ast_node *)op_node,
|
||||||
|
(struct ivy_ast_node *)tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ...and push the newly-completed operator node to the operand
|
/* ...and push the newly-completed operator node to the operand
|
||||||
|
|||||||
Reference in New Issue
Block a user