Ejemplo n.º 1
0
        public object Visit(ASTImplicitHighAndExpression node, object data)
        {
            object left = node.JjtGetChild(0).JjtAccept(this, data);

            if (node.JjtGetNumChildren() == 1)
            {
                return(left);
            }
            var right = (IQueryAtom)node.JjtGetChild(1).JjtAccept(this, data);

            return(LogicalOperatorAtom.And((IQueryAtom)left, right));
        }
Ejemplo n.º 2
0
        public object Visit(ASTReaction node, object data)
        {
            IAtomContainer query = new QueryAtomContainer(builder);

            for (int grpIdx = 0; grpIdx < node.JjtGetNumChildren(); grpIdx++)
            {
                int rollback = query.Atoms.Count;

                ASTGroup group = (ASTGroup)node.JjtGetChild(grpIdx);
                group.JjtAccept(this, query);

                // fill in the roles for newly create atoms
                if (group.Role != ReactionRoles.Any)
                {
                    IQueryAtom   roleQueryAtom = null;
                    ReactionRole?role          = null;

                    // use single instances
                    switch (group.Role)
                    {
                    case ReactionRoles.Reactant:
                        roleQueryAtom = ReactionRoleQueryAtom.RoleReactant;
                        role          = ReactionRole.Reactant;
                        break;

                    case ReactionRoles.Agent:
                        roleQueryAtom = ReactionRoleQueryAtom.RoleAgent;
                        role          = ReactionRole.Agent;
                        break;

                    case ReactionRoles.Product:
                        roleQueryAtom = ReactionRoleQueryAtom.RoleProduct;
                        role          = ReactionRole.Product;
                        break;
                    }

                    if (roleQueryAtom != null)
                    {
                        while (rollback < query.Atoms.Count)
                        {
                            IAtom org = query.Atoms[rollback];
                            IAtom rep = LogicalOperatorAtom.And(roleQueryAtom, (IQueryAtom)org);
                            // ensure AAM is propagated
                            rep.SetProperty(CDKPropertyName.AtomAtomMapping, org.GetProperty <int?>(CDKPropertyName.AtomAtomMapping));
                            rep.SetProperty(CDKPropertyName.ReactionRole, role);
                            AtomContainerManipulator.ReplaceAtomByAtom(query, org, rep);
                            rollback++;
                        }
                    }
                }
            }
            return(query);
        }
Ejemplo n.º 3
0
        public object Visit(ASTLowAndExpression node, object data)
        {
            var expr = (IAtom)node.JjtGetChild(0).JjtAccept(this, data);

            if (node.JjtGetNumChildren() > 1)
            {
                var right = (IQueryAtom)node.JjtGetChild(1).JjtAccept(this, data);
                expr = LogicalOperatorAtom.And((IQueryAtom)expr, right);
            }
            if (node.GetMapIdx() > 0)
            {
                expr.SetProperty(CDKPropertyName.AtomAtomMapping, node.GetMapIdx());
            }
            return(expr);
        }