Example #1
0
  @Override
  public void outAOperationSet(AOperationSet node) {
    try {
      CharSet cs1 = (CharSet) getOut(node.getLeft());
      CharSet cs2 = (CharSet) getOut(node.getRight());
      char binop = ((Character) getOut(node.getBinOp())).charValue();

      switch (binop) {
        case '+':
          {
            setOut(node, cs1.union(cs2));
          }
          break;
        case '-':
          {
            setOut(node, cs1.diff(cs2));
          }
          break;
      }
    } catch (Exception e) {
      throw new RuntimeException(node + " is invalid.");
    }

    // free memory
    if (getOut(node.getLeft()) != null) setOut(node.getLeft(), null);
    if (getOut(node.getBinOp()) != null) setOut(node.getBinOp(), null);
    if (getOut(node.getRight()) != null) setOut(node.getRight(), null);
  }