コード例 #1
0
  @Override
  public String toString() {
    StringBuffer result = new StringBuffer();

    result.append("{[LR0ItemCollection]" + System.getProperty("line.separator"));
    LR0ItemSet[] sets = sets();
    Symbol[] symbols = Symbol.symbols();

    for (int i = 0; i < sets.length; i++) {
      result.append(i + ":" + Grammar.CLOSURE(sets[i]));
      result.append(System.getProperty("line.separator"));

      for (int j = 0; j < symbols.length; j++) {
        if (GOTO(i, symbols[j]) != null) {
          result.append("[");
          result.append(symbols[j]);
          result.append(":");
          result.append(GOTO(i, symbols[j]));
          result.append("]");
        }
      }

      result.append(System.getProperty("line.separator"));
    }

    result.append("}");
    return result.toString();
  }
コード例 #2
0
  LR0Collection(LR0ItemSet set) {
    add(set, -1, null);

    for (int i = 0; i < sets.size(); i++) {
      System.out.print(".");
      Symbol[] symbols = Symbol.symbols();

      for (int j = 0; j < symbols.length; j++) {
        addGoto(i, symbols[j], Grammar.GOTO(set(i), symbols[j]));
      }
    }
    System.out.println();
  }