Example #1
0
  public Boolean ownsBlock(String name) {
    for (Block child : children) {
      if (child.getName().equals(name)) return true;
    }

    return false;
  }
Example #2
0
  @Override
  public String toString() {

    String str = "";

    for (Statement statement : statements) str += statement.toString();

    for (Block child : children) str += child.getName() + "[" + child.toString() + "]";

    return str;
  }
Example #3
0
  public Variable getVariable(String name) throws SyntaxException {

    Block block = this;

    while (block != null) {
      for (Variable var : block.getVariables()) {
        if (var.getName().equals(name)) return var;
      }

      block = block.getParent();
    }

    throw new SyntaxException("No variable named '" + name + "'.");
  }
Example #4
0
  public Boolean variableExists(String name) {

    Block block = this;

    while (block.getParent() != null) {
      for (Variable var : block.getVariables()) {
        if (var.getName().equals(name)) return true;
      }

      block = block.getParent();
    }

    return false;
  }
Example #5
0
  public Block getBlock(String name) {

    for (Block child : children) {
      if (child.getName().equals(name)) return child;
    }

    Block block;

    for (Block child : children) {
      if ((block = child.getBlock(name)) != null) return block;
    }

    return null;
  }
Example #6
0
  public Boolean isFather(Block block) {
    for (Block b : children) if (b.equals(block)) return true;

    return false;
  }