PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 0ms

/src/org/ooc/frontend/model/Parenthesis.java

http://github.com/nddrylliog/ooc
Java | 66 lines | 49 code | 17 blank | 0 comment | 2 complexity | ff078fbe37425dcc4b1519bf0b332f8a MD5 | raw file
 1package org.ooc.frontend.model;
 2
 3import java.io.IOException;
 4
 5import org.ooc.frontend.Visitor;
 6import org.ooc.frontend.model.tokens.Token;
 7
 8public class Parenthesis extends Expression {
 9
10	protected Expression expression;
11
12	public Parenthesis(Expression expression) {
13		super(expression.startToken);
14		this.expression = expression;
15	}
16	
17	public Parenthesis(Expression expression, Token startToken) {
18		super(startToken);
19		this.expression = expression;
20	}
21
22	public Expression getExpression() {
23		return expression;
24	}
25	
26	public void setExpression(Expression expression) {
27		this.expression = expression;
28	}
29
30	public Type getType() {
31		return expression.getType();
32	}
33
34	public void accept(Visitor visitor) throws IOException {
35		visitor.visit(this);
36	}
37	
38	public boolean hasChildren() {
39		return true;
40	}
41	
42	public void acceptChildren(Visitor visitor) throws IOException {
43		expression.accept(visitor);
44	}
45	
46	@Override
47	public boolean replace(Node oldie, Node kiddo) {
48		if(oldie == expression) {
49			expression = (Expression) kiddo;
50			return true;
51		}
52		
53		return false;
54	}
55	
56	@Override
57	public String toString() {
58		return "Parenthesis: (" + expression + ")";
59	}
60	
61	@Override
62	public boolean canBeReferenced() {
63		return expression.canBeReferenced();
64	}
65	
66}