Exemple #1
0
  @Override
  public Object visit(XorNode node) {
    StringBuilder sb = new StringBuilder();

    sb.append(" XOR ");
    sb.append(visit(node.GetLeftChild()));

    return sb.toString();
  }
Exemple #2
0
  @Override
  public Object visit(ElseNode node) {
    StringBuilder sb = new StringBuilder();

    sb.append("ELSE\n");
    sb.append(visit(node.GetLeftChild()));
    sb.append("END ELSE\n");

    return sb.toString();
  }
Exemple #3
0
  @Override
  public Object visit(LessNode node) {
    StringBuilder sb = new StringBuilder();

    sb.append(visit(node.GetLeftChild()));
    sb.append(" LESS_THAN ");
    sb.append(visit(node.GetRightChild()));

    return sb.toString();
  }
Exemple #4
0
  @Override
  public Object visit(GreaterNode node) {
    StringBuilder sb = new StringBuilder();

    sb.append(visit(node.GetLeftChild()));
    sb.append(" GREATER_THAN ");
    sb.append(visit(node.GetRightChild()));

    return sb.toString();
  }
Exemple #5
0
  @Override
  public Object visit(AssignNode node) {
    StringBuilder sb = new StringBuilder();

    sb.append(visit(node.GetLeftChild()));
    sb.append(" = ");
    sb.append(visit(node.GetRightChild()));

    return sb.toString();
  }
Exemple #6
0
  @Override
  public Object visit(BlockNode node) {
    StringBuilder sb = new StringBuilder();

    for (Node n : node.GetChildren()) {
      sb.append(visit(n));
      sb.append('\n');
    }

    return sb.toString();
  }
Exemple #7
0
  @Override
  public Object visit(LoadNode node) {
    StringBuilder sb = new StringBuilder();

    for (Node n : node.GetChildren()) {
      sb.append("LOAD(");
      sb.append(((ProgNode) n)._id);
      sb.append(")\n");
    }

    return sb.toString();
  }
Exemple #8
0
  @Override
  public Object visit(CollectionNode node) {
    StringBuilder sb = new StringBuilder();

    ArrayList<Node> children = node.GetChildren();

    for (int i = 0; i < children.size(); i++) {
      /*if(i > 0)
      sb.append(", ");*/
      sb.append(visit(children.get(i)));
    }

    return sb.toString();
  }
Exemple #9
0
  @Override
  public Object visit(LoopNode node) {
    StringBuilder sb = new StringBuilder();

    sb.append("REPEAT UNTIL(");
    sb.append(visit(node.GetLeftChild()));
    sb.append(")\n");
    sb.append(visit(node.GetRightChild()));
    sb.append("END REPEAT\n");

    return sb.toString();
  }
Exemple #10
0
  @Override
  public Object visit(NumDcl node) {
    StringBuilder sb = new StringBuilder();
    sb.append("NUM ");
    sb.append(visit(node.GetLeftChild()));

    if (node.GetRightChild() != null) {
      sb.append(" = ");
      sb.append(visit(node.GetRightChild()));
      sb.append('\n');
    }

    return sb.toString();
  }
Exemple #11
0
  @Override
  public Object visit(ListDcl node) {
    StringBuilder sb = new StringBuilder();
    sb.append("LIST ");
    sb.append(visit(node.GetLeftChild()));

    if (node.GetRightChild() != null) {
      sb.append(" = ");
      sb.append(visit(node.GetRightChild()));
      sb.append("END ");
    }

    return sb.toString();
  }
Exemple #12
0
  @Override
  public Object visit(SignalNode node) {
    StringBuilder sb = new StringBuilder();

    sb.append("SIGNAL ");
    sb.append(visit(node.GetLeftChild()));
    sb.append(visit(node.GetRightChild()));
    sb.append(")\n");

    return sb.toString();
  }
Exemple #13
0
  @Override
  public Object visit(MethodInvocationNode node) {
    StringBuilder sb = new StringBuilder();

    sb.append(visit(node.GetLeftChild()));
    sb.append('(');

    ArrayList<Node> children = node.GetChildren();

    for (int i = 0; i < children.size(); i++) {
      if (i > 0) sb.append(',');
      sb.append(visit(children.get(i)));
    }
    sb.append(")\n");

    return sb.toString();
  }
Exemple #14
0
  @Override
  public Object visit(MethodDcl node) {
    String id = node.id;
    StringBuilder sb = new StringBuilder();

    sb.append(node.getT());
    sb.append(' ');
    sb.append(node.id);
    sb.append('(');

    ArrayList<Node> params = node.parameters;

    for (int i = 0; i < params.size(); i++) {
      if (i > 0) sb.append(", ");
      sb.append(visit(params.get(i)));
    }

    sb.append(")\n");
    sb.append(visit(node.GetLeftChild()));
    sb.append("END ");
    sb.append(node.id);
    sb.append('\n');

    return sb.toString();
  }
Exemple #15
0
  @Override
  public Object visit(IfNode node) {
    StringBuilder sb = new StringBuilder();

    sb.append("IF (");
    sb.append(visit(node.GetCondition()));
    sb.append(")\n");
    sb.append(visit(node.GetBody()));
    sb.append("END IF\n");

    if (node.GetElseIf() != null) {
      sb.append(visit(node.GetElseIf()));
      sb.append('\n');
    }

    if (node.GetElse() != null) {
      sb.append(visit(node.GetElse()));
      sb.append('\n');
    }

    return sb.toString();
  }