use crate::{
query::adj_ast,
syntax::{
builders::binary_operation::build_binary_operation_node, SyntaxGraphArgs, SyntaxGraphError,
},
utilities::text_nodes::node_to_str,
NodeId,
};
use alloc::borrow::ToOwned;
pub fn reader(
args: &mut SyntaxGraphArgs<'_>,
n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
let graph = args.ast_graph;
let c_ids = adj_ast(graph, n_id, Some(1), &[]);
let (operator, left_id, right_id) = if let [left, op, right] = c_ids.as_slice() {
(node_to_str(graph, *op), Some(*left), Some(*right))
} else {
("UndefinedInfix".to_owned(), None, None)
};
build_binary_operation_node(args, n_id, operator, left_id, right_id).map(Some)
}