public static Object ReadAndGetFreeVariables(string exp, List<LogicVariable> variables) { ISOPrologReader r = new ISOPrologReader(exp); var term = r.ReadTerm(); variables.Clear(); variables.AddRange(r.vars); return term; }
protected override CodeTerm GetCodeTermBase(WamDeferenceTypes dereferenceType, WamReferenceTargetMapping mapping) { if (Functor == Functor.ListFunctor) { var head = new List<CodeTerm>(); CodeTerm tail = null; var codeTermHead = Children[0].GetCodeTerm(dereferenceType, mapping); var codeTermTail = Children[1].GetCodeTerm(dereferenceType, mapping); head.Add(codeTermHead); if (codeTermTail.IsCodeList) { head.AddRange(codeTermTail.AsCodeList.Head); tail = codeTermTail.AsCodeList.Tail; } else { tail = codeTermTail; } return new CodeList(head, tail); } if (Functor.Arity == 0) { return new CodeCompoundTerm(new CodeFunctor(Functor.Name)); } var children = new List<CodeTerm>(); foreach (var child in Children) { children.Add(child.GetCodeTerm(dereferenceType, mapping)); } return new CodeCompoundTerm(new CodeFunctor(Functor.Name, Functor.Arity), children); }