2 import java.util.Vector;
4 class BlockNode extends TreeNode {
5 Vector blockstatements;
7 public final static int NORMAL=0;
8 public final static int NOBRACES=1;
9 public final static int EXPRLIST=2;
12 blockstatements=new Vector();
15 public void addBlockStatement(BlockStatementNode bsn) {
16 blockstatements.add(bsn);
18 public void setStyle(int style) {
22 public String printNode(int indent) {
23 if (printStyle==NORMAL) {
25 for(int i=0;i<blockstatements.size();i++) {
26 BlockStatementNode bsn=(BlockStatementNode)blockstatements.get(i);
27 st+=printSpace(indent+INDENT)+bsn.printNode(indent+INDENT);
28 if (!((bsn instanceof SubBlockNode)||
29 (bsn instanceof LoopNode)||
30 (bsn instanceof IfStatementNode)))
32 if (bsn instanceof IfStatementNode)
35 st+=printSpace(indent)+"}";
37 } else if (printStyle==NOBRACES) {
39 for(int i=0;i<blockstatements.size();i++) {
40 BlockStatementNode bsn=(BlockStatementNode)blockstatements.get(i);
41 st+=printSpace(indent)+bsn.printNode(indent);
42 if (!((bsn instanceof SubBlockNode)||
43 (bsn instanceof LoopNode)||
44 (bsn instanceof IfStatementNode)))
48 } else if (printStyle==EXPRLIST) {
50 for(int i=0;i<blockstatements.size();i++) {
51 BlockStatementNode bsn=(BlockStatementNode)blockstatements.get(i);
53 if ((i+1)!=blockstatements.size())
57 } else throw new Error();