001    // See section 2.3 in the paper
002    
003    aspect PrintReachable {
004      public void StateMachine.printReachable() {
005        for (Declaration d : getDeclarations()) d.printReachable();
006      }
007        
008      public void Declaration.printReachable() { }
009        
010      public void State.printReachable() {
011        System.out.println(getLabel() + " can reach {" +
012            listOfReachableStateLabels() + "}");
013      }
014        
015      public String State.listOfReachableStateLabels() {
016        boolean insideList = false;
017        StringBuffer result = new StringBuffer();
018        for (State s : reachable()) {
019          if (insideList)
020            result.append(", ");
021          else
022            insideList = true;
023          result.append(s.getLabel());
024        }
025        return result.toString();
026      }
027    }