ModuloExpression.java
package edu.udel.cis.vsl.tass.model.impl.expression;
import edu.udel.cis.vsl.tass.model.IF.ModelFactoryIF;
import edu.udel.cis.vsl.tass.model.IF.SyntaxException;
import edu.udel.cis.vsl.tass.model.IF.type.TypeIF;
import edu.udel.cis.vsl.tass.model.IF.type.TypeIF.TypeKind;
public class ModuloExpression extends BinaryExpression {
public ModuloExpression(ModelFactoryIF factory, Expression left,
Expression right) throws SyntaxException {
super(factory, ExpressionKind.MODULO, left, right);
TypeIF leftType = left.type;
TypeIF rightType = right.type;
if (leftType.kind() != TypeKind.INTEGER)
throw new SyntaxException(left,
"Left argument to modulo operator must have integer type");
if (rightType.kind() != TypeKind.INTEGER)
throw new SyntaxException(right,
"Right argument to modulo operator must have integer type");
type = factory.integerType();
}
public String toString() {
return left.atomString() + "%" + right.atomString();
}
public String atomString() {
return "(" + this + ")";
}
}