コード例 #1
0
        public static ITerm AddAnnotToList(ITerm l, DefaultTerm source)
        {
            if (l.IsList())
            {
                IListTerm result = new ListTermImpl();
                foreach (ITerm lTerm in (IListTerm)l)
                {
                    ITerm t = AddAnnotToList(lTerm, source);
                    if (t != null)
                    {
                        result.Add(t);
                    }
                }
                return(result);
            }
            else if (l.IsLiteral())
            {
                Literal result = ((Literal)l).ForceFullLiteralImpl().Copy();

                //Create the source annots
                Literal ts = Pred.CreateSource(source).AddAnnots(result.GetAnnots("source"));

                result.DelSources();
                result.AddAnnots(ts);
                return(result);
            }
            else
            {
                return(l);
            }
        }