示例#1
0
  /**
   * Parse the <f> elements
   *
   * @return a list of tokens from the dictionary's entry
   */
  EntryToken procFlag() throws XMLStreamException {
    ArrayList<Integer> both_sides = new ArrayList<Integer>();
    // String n = attrib(COMPILER_N_ATTR);
    // String v = attrib(COMPILER_VALUE_ATTR);
    String name = "";
    reader.next();
    while (true) {
      if (reader.isEndElement() && reader.getLocalName().equals(COMPILER_FLAG_ELEM)) {
        break;
      }
      if (reader.isStartElement()) {
        name = reader.getLocalName();
        readString(both_sides, name);
        reader.next();
      } else if (reader.isCharacters()) {
        readString(both_sides, "");
        reader.next();
      } else if (reader.isEndElement()) {
        reader.next();
      } else {
        throw new RuntimeException(
            "Error ("
                + reader.getLocation().getLineNumber()
                + ","
                + reader.getLocation().getColumnNumber()
                + "): unexpected type of event.");
      }
    }

    /*
     * while (true) {
     * reader.next();
     * int type = reader.getEventType();
     * if (type == XMLStreamConstants.END_ELEMENT || type == XMLStreamConstants.START_ELEMENT) {
     * name = reader.getLocalName();
     *
     * System.err.println("name = " + name);
     * }
     * if (name.equals(COMPILER_FLAG_ELEM)) {
     * break;
     * }
     * readString(both_sides, name);
     * }
     */
    EntryToken e = new EntryToken();

    if (direction.equals(COMPILER_RESTRICTION_LR_VAL)) {
      e.setSingleTransduction(new ArrayList<Integer>(), both_sides);
    } else {
      e.setSingleTransduction(both_sides, new ArrayList<Integer>());
    }
    return e;
  }
示例#2
0
  /**
   * Parse the
   *
   * <p>elements
   *
   * @return a list of tokens from the dictionary's entry
   * @throws javax.xml.stream.XMLStreamException
   */
  EntryToken procTransduction() throws XMLStreamException {
    ArrayList<Integer> lhs = new ArrayList<Integer>();
    ArrayList<Integer> rhs = new ArrayList<Integer>();
    skipUntil("", COMPILER_LEFT_ELEM);
    reader.next();
    String name = "";
    while (true) {
      if (reader.isEndElement() && reader.getLocalName().equals(COMPILER_LEFT_ELEM)) {
        break;
      }
      if (reader.isStartElement()) {
        name = reader.getLocalName();
        readString(lhs, name);
        reader.next();
      } else if (reader.isCharacters()) {
        readString(lhs, "");
        reader.next();
      } else if (reader.isEndElement()) {
        reader.next();
      } else {
        throw new RuntimeException(
            "Error ("
                + reader.getLocation().getLineNumber()
                + ","
                + reader.getLocation().getColumnNumber()
                + "): unexpected type of event.");
      }
    }
    skipUntil(name, COMPILER_RIGHT_ELEM);
    reader.next();
    while (true) {
      if (reader.isEndElement() && reader.getLocalName().equals(COMPILER_RIGHT_ELEM)) {
        break;
      }
      if (reader.isStartElement()) {
        name = reader.getLocalName();
        readString(rhs, name);
        reader.next();
      } else if (reader.isCharacters()) {
        readString(rhs, "");
        reader.next();
      } else if (reader.isEndElement()) {
        reader.next();
      } else {
        throw new RuntimeException(
            "Error ("
                + reader.getLocation().getLineNumber()
                + ","
                + reader.getLocation().getColumnNumber()
                + "): unexpected type of event.");
      }
    }

    skipUntil(name, COMPILER_PAIR_ELEM);
    EntryToken e = new EntryToken();
    e.setSingleTransduction(lhs, rhs);
    return e;
  }
示例#3
0
 /**
  * Parse the <i> elements
  *
  * @return a list of tokens from the dictionary's entry
  * @throws javax.xml.stream.XMLStreamException
  */
 EntryToken procIdentity() throws XMLStreamException {
   ArrayList<Integer> both_sides = new ArrayList<Integer>();
   if (!(reader.isStartElement() && reader.isEndElement())) {
     // not an emoty node
   }
   String name = "";
   reader.next();
   while (true) {
     if (reader.isEndElement() && reader.getLocalName().equals(COMPILER_IDENTITY_ELEM)) {
       break;
     }
     if (reader.isStartElement()) {
       name = reader.getLocalName();
       readString(both_sides, name);
       reader.next();
     } else if (reader.isCharacters()) {
       readString(both_sides, "");
       reader.next();
     } else if (reader.isEndElement()) {
       reader.next();
     } else {
       throw new RuntimeException(
           "Error ("
               + reader.getLocation().getLineNumber()
               + ","
               + reader.getLocation().getColumnNumber()
               + "): unexpected type of event.");
     }
   }
   /*
    * while (true) {
    * reader.next();
    * int type = reader.getEventType();
    * if (type == XMLStreamConstants.END_ELEMENT || type == XMLStreamConstants.START_ELEMENT) {
    * name = reader.getLocalName();
    * }
    * if (name.equals(COMPILER_IDENTITY_ELEM)) {
    * break;
    * }
    * readString(both_sides, name);
    * }
    */
   EntryToken e = new EntryToken();
   e.setSingleTransduction(both_sides, both_sides);
   return e;
 }