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

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


    } else if (a1.isVariable()) {
      a2 = a2.dereference();
      if (a2.isVariable()) {
        throw new PInstantiationException(this, 2);
      } else if (a2.equals(SYM_NIL)) {
        throw new IllegalDomainException(this, 2, "non_empty_list", a2);
      } else if (!a2.isList()) {
        throw new IllegalTypeException(this, 2, "list", a2);
      }
      Term head = ((ListTerm) a2).car().dereference();
      Term tail = ((ListTerm) a2).cdr().dereference();
View Full Code Here


      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
View Full Code Here

    } else {
      throw new IllegalTypeException(this, 2, "compound", a2);
    }
    argNo = ((IntegerTerm) a1).intValue();
    if (argNo < 0) {
      throw new IllegalDomainException(this, 1, "not_less_than_zero", a1);
    }
    if (argNo > arity || argNo < 1) {
      return engine.fail();
    }
    if (!a3.unify(args[argNo - 1], engine.trail)) {
View Full Code Here

      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 PrintWriter)) {
      throw new PermissionException(this, "output", "stream", a1, "");
    }
    // print single character
View Full Code Here

    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    }
    if (!a1.isSymbol()) {
      throw new IllegalDomainException(this, 1, "source_sink", a1);
    }
    file = new File(((SymbolTerm) a1).name());
    // io_mode
    a2 = a2.dereference();
    if (a2.isVariable()) {
      throw new PInstantiationException(this, 2);
    }
    if (!a2.isSymbol()) {
      throw new IllegalTypeException(this, 2, "atom", a2);
    }
    try {
      if (a2.equals(SYM_READ)) {
        if (!file.exists()) {
          throw new ExistenceException(this, 1, "source_sink", a1, "");
        }
        PushbackReader in = new PushbackReader(new BufferedReader(
            new FileReader(file)), Prolog.PUSHBACK_SIZE);
        streamObject = new JavaObjectTerm(in);
        opts = new ListTerm(SYM_INPUT, opts);
      } else if (a2.equals(SYM_WRITE)) {
        PrintWriter out = new PrintWriter(new BufferedWriter(
            new FileWriter(file, false)));
        streamObject = new JavaObjectTerm(out);
        opts = new ListTerm(SYM_OUTPUT, opts);
      } else if (a2.equals(SYM_APPEND)) {
        PrintWriter out = new PrintWriter(new BufferedWriter(
            new FileWriter(file, true)));
        streamObject = new JavaObjectTerm(out);
        opts = new ListTerm(SYM_OUTPUT, opts);
      } else {
        throw new IllegalDomainException(this, 2, "io_mode", a2);
      }
    } catch (IOException e) {
      throw new PermissionException(this, "open", "source_sink", a1, "");
    }
    if (engine.getStreamManager().containsKey(streamObject)) {
      throw new InternalException("stream object is duplicated");
    }
    // stream_options
    a4 = a4.dereference();
    Term tmp = a4;
    while (!tmp.isNil()) {
      if (tmp.isVariable()) {
        throw new PInstantiationException(this, 4);
      }
      if (!tmp.isList()) {
        throw new IllegalTypeException(this, 4, "list", a4);
      }
      Term car = ((ListTerm) tmp).car().dereference();
      if (car.isVariable()) {
        throw new PInstantiationException(this, 4);
      }
      if (car.isStructure()) {
        SymbolTerm functor = ((StructureTerm) car).functor();
        Term[] args = ((StructureTerm) car).args();
        if (functor.equals(SYM_ALIAS_1)) {
          alias = args[0].dereference();
          if (!alias.isSymbol()) {
            throw new IllegalDomainException(this, 4,
                "stream_option", car);
          }
          if (engine.getStreamManager().containsKey(alias)) {
            throw new PermissionException(this, "open",
                "source_sink", car, "");
          }
        } else {
          throw new IllegalDomainException(this, 4, "stream_option",
              car);
        }
      } else {
        throw new IllegalDomainException(this, 4, "stream_option", car);
      }
      tmp = ((ListTerm) tmp).cdr().dereference();
    }
    Term[] args1 = { SYM_TEXT };
    Term[] args2 = { a2 };
View Full Code Here

      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 PrintWriter)) {
      throw new PermissionException(this, "output", "stream", a1, "");
    }
    engine.setCurrentOutput((PrintWriter) stream);
View Full Code Here

      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 token
View Full Code Here

      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, "");
    }
    engine.setCurrentInput((PushbackReader) stream);
View Full Code Here

      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
View Full Code Here

      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
View Full Code Here

TOP

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

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.