astra.term.Variable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of astra-interpreter Show documentation
Show all versions of astra-interpreter Show documentation
Core interpreter artifact for the ASTRA Language
package astra.term;
import astra.reasoner.util.LogicVisitor;
import astra.reasoner.util.StringMapper;
import astra.type.Type;
public class Variable implements Term {
/**
*
*/
private static final long serialVersionUID = 8088567323537166255L;
public static StringMapper mapper = new StringMapper();
private Type type;
private int id;
private boolean returns;
public Variable(Type type, String name) {
this(type, name, false);
}
public Variable(Type type, String name, boolean returns) {
this.id = mapper.toId(name);
this.type = type;
this.returns = returns;
}
public Variable(Type type, int key) {
this.id = key;
this.type = type;
}
@Override
public Type type() {
return type;
}
public int id() {
return id;
}
public String identifier() {
return mapper.fromId(id);
}
@Override
public Object accept(LogicVisitor visitor) {
return visitor.visit(this);
}
public String toString() {
return mapper.fromId(id)+":"+id;
}
@Override
public boolean matches(Term right) {
return type.equals(right.type());
}
public boolean returns() {
return returns;
}
@Override
public String signature() {
return null;
}
public Variable clone() {
return this;
}
}