fluidattacks-blends-domain 0.3.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::query::{adj_ast, match_ast};
use crate::syntax::builders::parenthesized_expression::build_parenthesized_expression_node;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::NodeId;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let expression_id = match match_ast(args.ast_graph, n_id, &[], None)
        .get("__1__")
        .copied()
        .flatten()
    {
        Some(expression_id) => expression_id,
        None => adj_ast(args.ast_graph, n_id, None, &[])
            .first()
            .copied()
            .ok_or(SyntaxGraphError::UnexpectedAstShape)?,
    };
    build_parenthesized_expression_node(args, n_id, expression_id).map(Some)
}