PrettyPrinting.jadd 1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
aspect PrettyPrinting {
  public String Relation.prettyPrint() {
    return "rel "
      + getLeft().prettyPrint() + " "
      + getDirection().prettyPrint() + " "
      + getRight().prettyPrint();
  }
  public String RelationComponent.prettyPrint() {
    if (getID().isEmpty()) {
      return getTypeUse().toString();
    } else {
      return getTypeUse() + "." +  getID();
    }
  }
  public String OptionalRelationComponent.prettyPrint() {
    return super.prettyPrint() + "?";
  }
  public String ManyRelationComponent.prettyPrint() {
    return super.prettyPrint() + "*";
  }
  abstract public String Direction.prettyPrint();
  public String RightDirection.prettyPrint() {
    return "->";
  }
  public String LeftDirection.prettyPrint() {
    return "<-";
  }
  public String Bidirectional.prettyPrint() {
    return "<->";
  }

}

aspect Utils {
  public String ASTNode.ind(int n) {
36
    StringBuilder s = new StringBuilder();
37
    for (int i = 0; i < n; i++) {
38
      s.append("  ");
39
    }
40
    return s.toString();
41
42
  }
}