Make function rules built-in

This commit is contained in:
Riccardo Azzolini 2019-02-10 19:59:38 +01:00
parent 7d9b08affd
commit b9c025d74c
15 changed files with 35 additions and 26 deletions

View File

@ -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();

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.DivisionRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.EmptyNumberRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.ExpressionRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.JokeRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.MultiplicationRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.NegativeRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.NumberRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.PowerRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.RootRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.SubtractionRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.SumRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.SumSubtractionRule

View File

@ -1,4 +1,4 @@
package rules.functions;
package it.cavallium.warppi.math.rules.functions;
/*
SETTINGS: (please don't move this part)
PATH=functions.VariableRule

View File

@ -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