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

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

    return sb.toString();
  }
示例#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();
  }
示例#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();
  }
示例#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();
  }
示例#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();
  }
示例#6
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();
  }
示例#7
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();
  }
示例#8
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();
  }
示例#9
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();
  }
示例#10
0
  @Override
  public Object visit(StringDcl node) {
    StringBuilder sb = new StringBuilder();
    sb.append("STRING ");
    sb.append(visit(node.GetLeftChild()));

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

    return sb.toString();
  }
示例#11
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();
  }
示例#12
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();
  }
示例#13
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();
  }
示例#14
0
  @Override
  public Object visit(HearDcl node) {
    String id = node.id;
    StringBuilder sb = new StringBuilder();

    sb.append("HEAR ");
    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(node.GetLeftChild());
    sb.append("END ");
    sb.append(node.id);
    sb.append('\n');

    return sb.toString();
  }