Exemplo n.º 1
0
        public static CodeTerm Create(XElement xCodeTerm)
        {
            foreach (var xSubtype in xCodeTerm.Elements())
            {
                if (xSubtype.Name == CodeValue.ElementName)
                {
                    return(CodeValue.Create(xSubtype));
                }
                if (xSubtype.Name == CodeVariable.ElementName)
                {
                    return(CodeVariable.Create(xSubtype));
                }
                if (xSubtype.Name == CodeCompoundTerm.ElementName)
                {
                    return(CodeCompoundTerm.Create(xSubtype));
                }
                if (xSubtype.Name == CodeList.ElementName)
                {
                    return(CodeList.Create(xSubtype));
                }

                throw new InvalidOperationException(string.Format("Unknown subtype element {0}", xSubtype.Name));
            }

            throw new InvalidOperationException("No subtype element specified.");
        }
Exemplo n.º 2
0
        public CodeSentence(IEnumerable <CodeComment> comments, CodeCompoundTerm head, IEnumerable <CodeCompoundTerm> body)
        {
            Comments = comments == null ? new CodeCommentList(new List <CodeComment>()) : new CodeCommentList(new List <CodeComment>(comments));

            Head = head;

            Body = body == null ? new CodeCompoundTermList(new List <CodeCompoundTerm>()) : new CodeCompoundTermList(new List <CodeCompoundTerm>(body));
        }
Exemplo n.º 3
0
        public CodeSentence(IEnumerable <CodeComment> comments, CodeCompoundTerm head, IEnumerable <CodeCompoundTerm> body)
        {
            if (comments == null)
            {
                m_comments = new CodeCommentList(new List <CodeComment>());
            }
            else
            {
                m_comments = new CodeCommentList(new List <CodeComment>(comments));
            }

            m_head = head;

            if (body == null)
            {
                m_body = new CodeCompoundTermList(new List <CodeCompoundTerm>());
            }
            else
            {
                m_body = new CodeCompoundTermList(new List <CodeCompoundTerm>(body));
            }
        }
Exemplo n.º 4
0
 public CodeList()
 {
     Head = new CodeTermList(new List <CodeTerm>());
     Tail = new CodeCompoundTerm(CodeFunctor.NilFunctor);
 }