Beispiel #1
0
 public object Visit(ASTRingIdentifier node, object data)
 {
     System.Console.Out.WriteLine(IndentString() + node);
     ++indent;
     data = node.ChildrenAccept(this, data);
     --indent;
     return(data);
 }
Beispiel #2
0
        public object Visit(ASTRingIdentifier node, object data)
        {
            IQueryAtom         atom       = (IQueryAtom)data;
            RingIdentifierAtom ringIdAtom = new RingIdentifierAtom(builder)
            {
                Atom = atom
            };
            IQueryBond bond;

            if (node.JjtGetNumChildren() == 0)
            {
                // implicit bond
                bond = null;
            }
            else
            {
                bond = (IQueryBond)node.JjtGetChild(0).JjtAccept(this, data);
            }
            ringIdAtom.RingBond = bond;
            return(ringIdAtom);
        }
Beispiel #3
0
        private void HandleRingClosure(IQueryAtom atom, ASTRingIdentifier ringIdentifier)
        {
            RingIdentifierAtom ringIdAtom = (RingIdentifierAtom)ringIdentifier.JjtAccept(this, atom);

            // if there is already a RingIdentifierAtom, create a bond between
            // them and add the bond to the query
            int ringId = ringIdentifier.RingId;

            // ring digit > 9 - expand capacity
            if (ringId >= ringAtoms.Length)
            {
                ringAtoms = Arrays.CopyOf(ringAtoms, 100);
            }

            // Ring Open
            if (ringAtoms[ringId] == null)
            {
                ringAtoms[ringId] = ringIdAtom;
                if (neighbors.ContainsKey(atom))
                {
                    neighbors[atom].Add(ringIdAtom);
                }
            }

            // Ring Close
            else
            {
                IQueryBond ringBond;
                // first check if the two bonds ma
                if (ringAtoms[ringId].RingBond == null)
                {
                    if (ringIdAtom.RingBond == null)
                    {
                        if (atom is AromaticSymbolAtom &&
                            ringAtoms[ringId].Atom is AromaticSymbolAtom)
                        {
                            ringBond = new AromaticQueryBond(builder);
                        }
                        else
                        {
                            ringBond = new RingBond(builder);
                        }
                    }
                    else
                    {
                        ringBond = ringIdAtom.RingBond;
                    }
                }
                else
                {
                    // Here I assume the bond are always same. This should be checked by the parser already
                    ringBond = ringAtoms[ringId].RingBond;
                }
                ((IBond)ringBond).SetAtoms(new[] { ringAtoms[ringId].Atom, atom });
                query.Bonds.Add((IBond)ringBond);

                // if the connected atoms was tracking neighbors, replace the
                // placeholder reference
                if (neighbors.ContainsKey(ringAtoms[ringId].Atom))
                {
                    IList <IAtom> localNeighbors = neighbors[ringAtoms[ringId].Atom];
                    localNeighbors[localNeighbors.IndexOf(ringAtoms[ringId])] = atom;
                }
                if (neighbors.ContainsKey(atom))
                {
                    neighbors[atom].Add(ringAtoms[ringId].Atom);
                }
                ringAtoms[ringId] = null;
            }
        }
Beispiel #4
0
 public object Visit(ASTRingIdentifier node, object data)
 {
     // TODO Auto-generated method stub
     return(null);
 }