com.github.leeonky.interpreter.Operator Maven / Gradle / Ivy
The newest version!
package com.github.leeonky.interpreter;
public abstract class Operator, O extends Operator,
E extends Expression> {
protected final int precedence;
protected final String label;
private int position;
public Operator(int precedence, String label) {
this.precedence = precedence;
this.label = label;
}
public boolean isPrecedentThan(O operator) {
return precedence > operator.precedence;
}
public abstract Object calculate(E expression, C context);
public int getPosition() {
return position;
}
@SuppressWarnings("unchecked")
public O setPosition(int position) {
this.position = position;
return (O) this;
}
}