Make function rules built-in
This commit is contained in:
parent
7d9b08affd
commit
b9c025d74c
@ -10,6 +10,7 @@ import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import it.cavallium.warppi.Engine;
|
||||
import it.cavallium.warppi.Platform.ConsoleUtils;
|
||||
@ -23,6 +24,7 @@ import it.cavallium.warppi.math.functions.Variable;
|
||||
import it.cavallium.warppi.math.functions.Variable.V_TYPE;
|
||||
import it.cavallium.warppi.math.rules.dsl.DslAggregateException;
|
||||
import it.cavallium.warppi.math.rules.dsl.RulesDsl;
|
||||
import it.cavallium.warppi.math.rules.functions.*;
|
||||
import it.cavallium.warppi.math.solver.MathSolver;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
@ -41,6 +43,8 @@ public class RulesManager {
|
||||
RulesManager.rules[val.ordinal()] = new ObjectArrayList<>();
|
||||
}
|
||||
|
||||
loadBuiltinRules();
|
||||
|
||||
try {
|
||||
loadDslRules();
|
||||
|
||||
@ -159,6 +163,24 @@ public class RulesManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadBuiltinRules() {
|
||||
Stream.of(
|
||||
new DivisionRule(),
|
||||
new EmptyNumberRule(),
|
||||
new ExpressionRule(),
|
||||
new JokeRule(),
|
||||
new MultiplicationRule(),
|
||||
new NegativeRule(),
|
||||
new NumberRule(),
|
||||
new PowerRule(),
|
||||
new RootRule(),
|
||||
new SubtractionRule(),
|
||||
new SumRule(),
|
||||
new SumSubtractionRule(),
|
||||
new VariableRule()
|
||||
).forEach(RulesManager::addRule);
|
||||
}
|
||||
|
||||
private static void loadDslRules() throws IOException, DslAggregateException {
|
||||
final StorageUtils storageUtils = Engine.getPlatform().getStorageUtils();
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.DivisionRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.EmptyNumberRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.ExpressionRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.JokeRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.MultiplicationRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.NegativeRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.NumberRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.PowerRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.RootRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.SubtractionRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.SumRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.SumSubtractionRule
|
@ -1,4 +1,4 @@
|
||||
package rules.functions;
|
||||
package it.cavallium.warppi.math.rules.functions;
|
||||
/*
|
||||
SETTINGS: (please don't move this part)
|
||||
PATH=functions.VariableRule
|
@ -1,15 +1,2 @@
|
||||
functions/DivisionRule
|
||||
functions/EmptyNumberRule
|
||||
functions/ExpressionRule
|
||||
functions/JokeRule
|
||||
functions/MultiplicationRule
|
||||
functions/NegativeRule
|
||||
functions/NumberRule
|
||||
functions/PowerRule
|
||||
functions/RootRule
|
||||
functions/SubtractionRule
|
||||
functions/SumRule
|
||||
functions/SumSubtractionRule
|
||||
functions/VariableRule
|
||||
ExpandRule1
|
||||
ExponentRule17
|
Loading…
Reference in New Issue
Block a user