Package net.sf.kpex.prolog

Examples of net.sf.kpex.prolog.Term


  }

  private final Term getConjCont(Term curr) throws IOException
  {

    Term n = next();
    Term t = null;
    if (n instanceof EocToken)
    {
      t = curr;
    }
    else if (n instanceof CommaToken)
    {
      Term other = getTerm();
      t = new Conj(curr, getConjCont(other));
    }
    if (null == t)
    {
      throw new ParserException("'.'", "bad body element", n);
View Full Code Here


    return t;
  }

  private final Term getList() throws IOException
  {
    Term n = next();
    if (n instanceof RbraToken)
    {
      return Const.NIL;
    }
    Term t = getTerm(n);
    return getListCont(t);
  }
View Full Code Here

  @Override
  public int exec(Prog p)
  {
    String title = getArg(0).toUnquoted();
    LayoutManager L = GuiBuiltins.to_layout(getArg(1));
    Term frameTerm = new JavaObject(new JinniFrame(title, L));
    return putArg(2, frameTerm, p);
  }
View Full Code Here

  }

  private final Term getListCont(Term curr) throws IOException
  {
    // IO.trace("curr: "+curr);
    Term n = next();
    Term t = null;
    if (n instanceof RbraToken)
    {
      t = new Cons(curr, Const.NIL);
    }
    else if (n instanceof BarToken)
    {
      t = new Cons(curr, getTerm());
      n = next();
      if (!(n instanceof RbraToken))
      {
        throw new ParserException("']'", "bad list end after '|'", n);
      }
    }
    else if (n instanceof CommaToken)
    {
      Term other = getTerm();
      t = new Cons(curr, getListCont(other));
    }
    if (t == null)
    {
      throw new ParserException("| or ]", "bad list continuation", n);
View Full Code Here

  private Clause readClauseOrEOF() throws IOException
  {

    dict = new HashMap();

    Term n = next();

    // IO.mes("readClauseOrEOF 0:"+n);

    if (n instanceof EofToken)
    {
      return null; // $$toClause(n.token(),dict);
    }

    if (n instanceof IffToken)
    {
      n = next();
      Term t = getTerm(n);
      Term bs = getConjCont(t);
      Clause C = new Clause(new Const("init"), bs);
      C.dict = dict;
      return C;
    }

    Term h = getTerm(n);

    // IO.mes("readClauseOrEOF 1:"+h);

    n = next();

    // IO.mes("readClauseOrEOF 2:"+n);

    if (n instanceof EocToken || n instanceof EofToken)
    {
      return toClause(h, dict);
    }

    // IO.mes("readClauseOrEOF 3:"+b);

    Clause C = null;
    if (n instanceof IffToken)
    {
      Term t = getTerm();
      Term bs = getConjCont(t);
      C = new Clause(h, bs);
      C.dict = dict;
    }
    else if (n instanceof CommaToken)
    {
      Term b = getTerm();
      Term bs = getConjCont(b);
      C = toClause(new Conj(h, bs), dict);
    }
    else
    {
      throw new ParserException("':-' or '.' or ','", "bad body element", n);
View Full Code Here

    // IO.mes("unwind TRAIL: "+name()+": "+size()+"=>"+to);
    // if(to>size())
    // IO.assertion("unwind attempted from smaller to larger top");
    for (int i = size() - to; i > 0; i--)
    {
      Term V = pop();
      V.undoBinding();
    }
  }
View Full Code Here

  {
    Source from = (Source) getArg(0);
    Sink to = (Sink) getArg(1);
    for (;;)
    {
      Term X = from.getElement();
      if (null == X)
      {
        to.stop();
        break;
      }
View Full Code Here

   * @see net.sf.kpex.prolog.FunBuiltin#exec(net.sf.kpex.prolog.Prog)
   */
  @Override
  public int exec(Prog p)
  {
    Term I = getArg(0);
    Fluent f;
    if (I instanceof CharReader)
    {
      f = new CharReader(((CharReader) I), p);
    }
View Full Code Here

  @Override
  public int exec(Prog p)
  {
    Fluent F = (Fluent) getArg(0);
    Term R = F.isPersistent() ? Const.YES : Const.NO;
    return putArg(1, R, p);
  }
View Full Code Here

   */
  @Override
  public int exec(Prog p)
  {
    DataBase db = (DataBase) ((JavaObject) getArg(0)).toObject();
    Term X = getArg(1);
    Term R = db.all(X.getKey(), X);
    return putArg(2, R, p);
  }
View Full Code Here

TOP

Related Classes of net.sf.kpex.prolog.Term

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.