diff options
Diffstat (limited to 'src/main/java/io/devnulllabs/openjava/ptree/WhileStatement.java')
-rw-r--r-- | src/main/java/io/devnulllabs/openjava/ptree/WhileStatement.java | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/main/java/io/devnulllabs/openjava/ptree/WhileStatement.java b/src/main/java/io/devnulllabs/openjava/ptree/WhileStatement.java new file mode 100644 index 0000000..81c4eb3 --- /dev/null +++ b/src/main/java/io/devnulllabs/openjava/ptree/WhileStatement.java @@ -0,0 +1,84 @@ +/** + * The WhileStatement class presents while statement node + * of parse tree + * + * Jun 20, 1997 by mich + * Sep 29, 1997 by mich + * Oct 11, 1997 by mich + * + * @see io.devnulllabs.openjava.ptree.ParseTree + * @version 1.0 last updated: Oct 11, 1997 + * @author Michiaki Tatsubori + */ +package io.devnulllabs.openjava.ptree; + +import io.devnulllabs.openjava.ptree.util.ParseTreeVisitor; + +/** + * The WhileStatement class presents while statement node + * of parse tree + * + * @see io.devnulllabs.openjava.ptree.ParseTree + * @see io.devnulllabs.openjava.ptree.NonLeaf + * @see io.devnulllabs.openjava.ptree.Statement + */ +public class WhileStatement extends NonLeaf implements Statement, ParseTree { + + /** + * Allocates a new object. + * + * @param expr the expression of the condition of this while + * statement. + * @param stmts the statement list of the body oof this while + * statement. + */ + public WhileStatement(Expression expr, StatementList stmts) { + super(); + set((ParseTree) expr, (ParseTree) stmts); + } + + WhileStatement() { + super(); + } + + /** + * Gets the condtion of this while statement. + * + * @return the expression of the condtion. + */ + public Expression getExpression() { + return (Expression) elementAt(0); + } + + /** + * Sets the condtion of this while statement. + * + * @param expr the expression of the condtion to set. + */ + public void setExpression(Expression expr) { + setElementAt(expr, 0); + } + + /** + * Gets the body of this while statement. + * + * @return the statement list of the body. + */ + public StatementList getStatements() { + return (StatementList) elementAt(1); + } + + /** + * Sets the body of this while statement. + * + * @param stmts the statement list of the body to set. + */ + public void setStatements(StatementList stmts) { + setElementAt(stmts, 1); + } + + public void accept(ParseTreeVisitor v) throws ParseTreeException { + v.visit(this); + } + +} |