You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
901 B
41 lines
901 B
package chocopy.common.astnodes;
|
|
|
|
import chocopy.common.analysis.NodeAnalyzer;
|
|
import java_cup.runtime.ComplexSymbolFactory.Location;
|
|
|
|
/**
|
|
* Conditional expressions.
|
|
*/
|
|
public class IfExpr extends Expr {
|
|
/**
|
|
* Boolean condition.
|
|
*/
|
|
public final Expr condition;
|
|
/**
|
|
* True branch.
|
|
*/
|
|
public final Expr thenExpr;
|
|
/**
|
|
* False branch.
|
|
*/
|
|
public final Expr elseExpr;
|
|
|
|
/**
|
|
* The AST for
|
|
* THENEXPR if CONDITION else ELSEEXPR
|
|
* spanning source locations [LEFT..RIGHT].
|
|
*/
|
|
public IfExpr(Location left, Location right,
|
|
Expr condition, Expr thenExpr, Expr elseExpr) {
|
|
super(left, right);
|
|
this.condition = condition;
|
|
this.thenExpr = thenExpr;
|
|
this.elseExpr = elseExpr;
|
|
}
|
|
|
|
public <T> T dispatch(NodeAnalyzer<T> analyzer) {
|
|
return analyzer.analyze(this);
|
|
}
|
|
|
|
}
|