Package jp.ac.kobe_u.cs.prolog.lang

Examples of jp.ac.kobe_u.cs.prolog.lang.RepresentationException


        throw e;
      }
    }
    n = ((NumberTerm) a2).intValue();
    if (!Character.isDefined(n)) {
      throw new RepresentationException(this, 2, "character_code");
    }
    // S_or_a
    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getStreamManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "stream", a1, "");
      }
      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
    } else {
      throw new IllegalDomainException(this, 1, "stream_or_alias", a1);
    }
    if (!(stream instanceof PushbackReader)) {
      throw new PermissionException(this, "input", "stream", a1, "");
    }
    // skip
    try {
      PushbackReader in = (PushbackReader) stream;
      int c = in.read();
      while (c != n) {
        c = in.read();
        if (c == -1) {
          return cont;
        }
        if (!Character.isDefined(c)) {
          throw new RepresentationException(this, 0, "character");
        }
      }
      return cont;
    } catch (IOException e) {
      throw new TermException(new JavaObjectTerm(e));
View Full Code Here


          return engine.fail();
        }
        return cont;
      }
      if (!Character.isDefined(c)) {
        throw new RepresentationException(this, 0, "character");
      }
      if (!a2.unify(SymbolTerm.makeSymbol(String.valueOf((char) c)),
          engine.trail)) {
        return engine.fail();
      }
View Full Code Here

          return engine.fail();
        }
        return cont;
      }
      if (!Character.isDefined(c)) {
        throw new RepresentationException(this, 0, "character");
      }
      ((PushbackReader) stream).unread(c);
      if (!a2.unify(SymbolTerm.makeSymbol(String.valueOf((char) c)),
          engine.trail)) {
        return engine.fail();
View Full Code Here

      if (!a2.isInteger()) {
        throw new IllegalTypeException(this, 2, "integer", a2);
      }
      int n = ((IntegerTerm) a2).intValue();
      if (n != -1 && !Character.isDefined(n)) {
        throw new RepresentationException(this, 2, "in_character_code");
      }
    }
    // S_or_a
    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getStreamManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "stream", a1, "");
      }
      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
          .object();
    } else if (a1.isJavaObject()) {
      stream = ((JavaObjectTerm) a1).object();
    } else {
      throw new IllegalDomainException(this, 1, "stream_or_alias", a1);
    }
    if (!(stream instanceof PushbackReader)) {
      throw new PermissionException(this, "input", "stream", a1, "");
    }
    // read single character
    try {
      int c = ((PushbackReader) stream).read();
      if (c < 0) { // EOF
        if (!a2.unify(INT_EOF, engine.trail)) {
          return engine.fail();
        }
        return cont;
      }
      if (!Character.isDefined(c)) {
        throw new RepresentationException(this, 0, "character");
      }
      if (!a2.unify(new IntegerTerm(c), engine.trail)) {
        return engine.fail();
      }
      return cont;
View Full Code Here

        Term car = ((ListTerm) x).car().dereference();
        if (car.isVariable()) {
          throw new PInstantiationException(this, 2);
        }
        if (!car.isInteger()) {
          throw new RepresentationException(this, 2, "character_code");
        }
        // car is an integer
        int i = ((IntegerTerm) car).intValue();
        if (!Character.isDefined((char) i)) {
          throw new RepresentationException(this, 2, "character_code");
        }
        sb.append((char) i);
        x = ((ListTerm) x).cdr().dereference();
      }
      try {
View Full Code Here

TOP

Related Classes of jp.ac.kobe_u.cs.prolog.lang.RepresentationException

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.