Example #1
0
  /**
   * Parse the type attribute of <Expr>, <Ind>, <Data> and <Var> elements.
   *
   * @param element The element whose type attribute should be parsed.
   * @return A unique numeric identifier generated by the type system.
   * @throws ParseException Thrown if the type specified in the type attribute is invalid.
   */
  private int parseTypeAttribute(Element element) throws ParseException {
    Attribute type = element.getAttribute(tagNames.TYPE);

    int typeid = Types.IOBJECT;

    if (type != null) {
      typeid = Types.typeID(type.getValue().trim());
      if (typeid == -1) {
        throw new ParseException("Type " + type.getValue().trim() + " is not defined.");
      }
    }

    return typeid;
  }
Example #2
0
  /**
   * A method to find the normalized types for each variable in the clause.
   *
   * @return A hash table containing the normalized type for each variable in the current clause.
   * @throws ParseException A ParseException is thrown a variable does not have a normalized form
   *     (type that is an intersection of all given types); since Nothing inherits from all types
   *     this should never occur.
   */
  private Hashtable<Integer, Integer> buildTypeTable() throws ParseException {
    Hashtable<Integer, Integer> ht = new Hashtable<Integer, Integer>();
    Enumeration<Integer> e = varClasses.keys();

    while (e.hasMoreElements()) {
      int key = e.nextElement();
      Vector<Integer> value = varClasses.get(key);
      int[] types = new int[value.size()];
      for (int i = 0; i < types.length; i++) {
        types[i] = ((Integer) value.get(i)).intValue();
      }

      int type = Types.greatestLowerBound(types);
      ht.put(key, type);
    }
    return ht;
  }