blob: 585a39bf992a2a0ceec3be5d24cda14ca8d22ad7 (
plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*
* Block.java 1.0
*
* Jun 11, 1997 by mich
* Aug 29, 1997 by mich
*
* @see io.devnulllabs.openjava.ptree.ParseTree
* @version last updated: Aug 29, 1997
* @author Michiaki Tatsubori
*/
package io.devnulllabs.openjava.ptree;
import io.devnulllabs.openjava.ptree.util.ParseTreeVisitor;
/**
* The Block class represents a node of parse tree
* of block statement like :
* <br><blockquote><pre>
* {
* int i = 0;
* i = f( i );
* }
* </pre></blockquote><br>
*
* @see io.devnulllabs.openjava.ptree.NonLeaf
* @see io.devnulllabs.openjava.ptree.Statement
*/
public class Block extends NonLeaf implements Statement {
/**
* Allocates a new object.
*
* @param stmts statement list.
*/
public Block(StatementList stmts) {
super();
if (stmts == null)
stmts = new StatementList();
set(stmts);
}
/**
* Allocates a new object with an empty statement list.
*
*/
public Block() {
this(new StatementList());
}
/**
* Gets the statement list of this block.
*
* @return the statement list.
*/
public StatementList getStatements() {
return (StatementList) elementAt(0);
}
/**
* Sets the statement list of this block.
*
* @param stmts the statement list to set.
*/
public void setStatements(StatementList stmts) {
setElementAt(stmts, 0);
}
public void accept(ParseTreeVisitor v) throws ParseTreeException {
v.visit(this);
}
}
|