Exemple #1
0
  @Override
  public void outAUnExp(AUnExp node) {
    Object o = getOut(node.getBasic());

    char c = ' ';
    if (node.getUnOp() != null) c = ((Character) getOut(node.getUnOp())).charValue();

    switch (c) {
      case '*':
        {
          NFA n = (o instanceof NFA) ? (NFA) o : new NFA((CharSet) o);
          setOut(node, n.zeroOrMore());
        }
        break;
      case '?':
        {
          NFA n = (o instanceof NFA) ? (NFA) o : new NFA((CharSet) o);
          setOut(node, n.zeroOrOne());
        }
        break;
      case '+':
        {
          NFA n = (o instanceof NFA) ? (NFA) o : new NFA((CharSet) o);
          setOut(node, n.oneOrMore());
        }
        break;
      default:
        {
          setOut(node, o);
        }
        break;
    }

    // free memory
    if (getOut(node.getBasic()) != null) setOut(node.getBasic(), null);
    if (getOut(node.getUnOp()) != null) setOut(node.getUnOp(), null);
  }