Exemple #1
0
    private PredicateDescr SetClauseList(PredEnum predType, string f, int a, ClauseNode c)
    {
      string key = Term.Key(f, a);
      PredicateDescr pd = this[key];

      if (pd == null)
      {
        switch (predType)
        {
#if persistent
          case PredEnum.table:
            this [key] = pd = new TablePredDescr (Globals.ConsultModuleName, Globals.ConsultFileName, f, a, c);
            break;
          case PredEnum.selproc:
            this [key] = pd = new ProcedurePredDescr (Globals.ConsultModuleName, Globals.ConsultFileName, f, a, c, true);
            break;
          case PredEnum.execproc:
            this [key] = pd = new ProcedurePredDescr (Globals.ConsultModuleName, Globals.ConsultFileName, f, a, c, false);
            break;
#endif
          default:
          	if (f.Contains("::"))
            {
            	String[] parts = Regex.Split(f, "::");
                double prob = Double.Parse(parts[0], Globals.CI);
                long timestamp = 0L;
                string clauseText = "";
                if (parts.Length == 3)
                {
                    if ("T".Equals(parts[1]))
                    {
                        timestamp = DateTime.Now.Ticks;
                    }
                    else
                    {
                        timestamp = DateTime.Now.Ticks + long.Parse(parts[1]) *10000000;
                    }
                    clauseText = parts[2];
                }
                else
                {
                    clauseText = parts[1];
                }
                Parser np = new Parser(null);
                np.StreamIn = clauseText + ".";
                Term goalTerm = np.QueryNode.Term;
                key = Term.Key(goalTerm.Functor, goalTerm.Arity);
                ClauseNode cn = new ClauseNode(goalTerm, null, prob, timestamp);
                if (this[key] == null)
                {
                    this[key] = pd = new PredicateDescr(Globals.ConsultModuleName, Globals.ConsultFileName, goalTerm.Functor, goalTerm.Arity, cn);
                }
                else
                {
                    pd = this[key];
                    pd.AppendToClauseList(cn);
                }
            }
            else
            {
                this[key] = pd = new PredicateDescr(Globals.ConsultModuleName, Globals.ConsultFileName, f, a, c);
            }
            break;
        }
      }
      else
        pd.SetClauseListHead(c);

      pd.AdjustClauseListEnd();

      return pd;
    }
Exemple #2
0
 public Symbol(Parser p)
 {
     parser = p;
     processed = false;
     OValue = null;
     Type = 0;
     Terminal = Parser.Undefined;
     Start = UNDEF;
     Final = UNDEF;
     FinalPlus = UNDEF;
     PrevFinal = UNDEF;
     LineNo = UNDEF;
     LineStart = UNDEF;
     AbsSeqNo = UNDEF;
     RelSeqNo = UNDEF;
     HasIdFormat = false;
 }
Exemple #3
0
 public PrologEngine()
 {
     parser = new Parser(ps);
       ReadBuiltinPredicates();
 }