Example #1
0
 /// <summary>
 /// Construct a fact, ground or variable, from a GdlExpression. Returns a
 /// GroundFact if there were no variables in the GdlExpression, and a
 /// VariableFact otherwise.
 /// </summary>
 /// <param name="exp">The expression from which to construct the fact.</param>
 /// <returns>The fact constructed from GdlExpression <paramref name="exp"/>.</returns>
 public static Fact FromExpression(GdlExpression exp)
 {
     // When in doubt, it's probably a variable fact.
     // Besides, the variable fact factory takes care of turning
     // things into ground facts if there are no variables.
     return VariableFact.FromExpression(exp);
 }
Example #2
0
        public static new Fact FromExpression(GdlExpression exp)
        {
            if (exp is GdlAtom)
                return GroundFact.FromExpression(exp);

            var list = exp as GdlList;
            if (list != null)
                return FromList(list);

            // unknown expression type
            throw new Exception("GroundFact.fromExpression: don't know how to handle expressions of type " + exp.GetType().Name);
        }
Example #3
0
        private void ExamineTerm(GdlExpression exp)
        {
            var atom = exp as GdlAtom;
            if (atom != null)
                ExamineAtomTerm(atom);

            else if (exp is GdlVariable)
                ExamineVariableTerm();

            else
            {
                var list = exp as GdlList;
                if (list != null)
                    ExamineListTerm(list);
                else
                    throw new Exception("MetaGdl.examineTerm: can't handle expressions of type " + exp.GetType().Name);
            }
        }
Example #4
0
        public Expression ExamineRelation(GdlExpression relation)
        {
            var atom = relation as GdlAtom;
            if (atom != null)
                return ExamineAtomRelation(atom);

            // else, must be a variable
            var list = (GdlList)relation;
            return ExamineListRelation((GdlList)relation, ((GdlAtom)list[0]).GetToken());
        }