mirror of
https://github.com/DanilaFe/abacus
synced 2026-01-11 17:45:20 +00:00
Add operator types.
This commit is contained in:
@@ -3,6 +3,7 @@ package org.nwapw.abacus.plugin;
|
||||
import org.nwapw.abacus.function.Function;
|
||||
import org.nwapw.abacus.function.Operator;
|
||||
import org.nwapw.abacus.function.OperatorAssociativity;
|
||||
import org.nwapw.abacus.function.OperatorType;
|
||||
import org.nwapw.abacus.number.NaiveNumber;
|
||||
import org.nwapw.abacus.number.NumberInterface;
|
||||
|
||||
@@ -20,7 +21,7 @@ public class StandardPlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
registerOperator("+", new Operator(OperatorAssociativity.LEFT, 0, new Function() {
|
||||
registerOperator("+", new Operator(OperatorAssociativity.LEFT, OperatorType.BINARY_INFIX, 0, new Function() {
|
||||
@Override
|
||||
protected boolean matchesParams(NumberInterface[] params) {
|
||||
return params.length >= 1;
|
||||
@@ -36,7 +37,7 @@ public class StandardPlugin extends Plugin {
|
||||
}
|
||||
}));
|
||||
|
||||
registerOperator("-", new Operator(OperatorAssociativity.LEFT, 0, new Function() {
|
||||
registerOperator("-", new Operator(OperatorAssociativity.LEFT, OperatorType.BINARY_INFIX, 0, new Function() {
|
||||
@Override
|
||||
protected boolean matchesParams(NumberInterface[] params) {
|
||||
return params.length == 2;
|
||||
@@ -48,7 +49,7 @@ public class StandardPlugin extends Plugin {
|
||||
}
|
||||
}));
|
||||
|
||||
registerOperator("*", new Operator(OperatorAssociativity.LEFT, 1, new Function() {
|
||||
registerOperator("*", new Operator(OperatorAssociativity.LEFT, OperatorType.BINARY_INFIX,1, new Function() {
|
||||
@Override
|
||||
protected boolean matchesParams(NumberInterface[] params) {
|
||||
return params.length >= 1;
|
||||
@@ -64,7 +65,7 @@ public class StandardPlugin extends Plugin {
|
||||
}
|
||||
}));
|
||||
|
||||
registerOperator("/", new Operator(OperatorAssociativity.LEFT, 1, new Function() {
|
||||
registerOperator("/", new Operator(OperatorAssociativity.LEFT, OperatorType.BINARY_INFIX,1, new Function() {
|
||||
@Override
|
||||
protected boolean matchesParams(NumberInterface[] params) {
|
||||
return params.length == 2;
|
||||
@@ -76,7 +77,7 @@ public class StandardPlugin extends Plugin {
|
||||
}
|
||||
}));
|
||||
|
||||
registerOperator("^", new Operator(OperatorAssociativity.RIGHT, 2, new Function() {
|
||||
registerOperator("^", new Operator(OperatorAssociativity.RIGHT, OperatorType.BINARY_INFIX, 2, new Function() {
|
||||
@Override
|
||||
protected boolean matchesParams(NumberInterface[] params) {
|
||||
return params.length == 2;
|
||||
|
||||
Reference in New Issue
Block a user