use of org.matheclipse.core.eval.exception.RuleCreationError in project symja_android_library by axkr.
the class PatternMatching method setDownRule.
public static Object[] setDownRule(IExpr leftHandSide, IExpr rightHandSide, boolean packageMode) {
final Object[] result = new Object[] { null, rightHandSide };
if (leftHandSide.isAST()) {
final ISymbol lhsSymbol = ((IAST) leftHandSide).topHead();
result[0] = lhsSymbol.putDownRule(ISymbol.RuleType.SET, false, leftHandSide, rightHandSide, packageMode);
return result;
}
if (leftHandSide.isSymbol()) {
final ISymbol lhsSymbol = (ISymbol) leftHandSide;
if (lhsSymbol.hasLocalVariableStack()) {
lhsSymbol.set(rightHandSide);
return result;
}
result[0] = lhsSymbol.putDownRule(ISymbol.RuleType.SET, true, leftHandSide, rightHandSide, packageMode);
return result;
}
throw new RuleCreationError(leftHandSide);
}
use of org.matheclipse.core.eval.exception.RuleCreationError in project symja_android_library by axkr.
the class PatternMatching method setDelayedDownRule.
public static Object[] setDelayedDownRule(IExpr leftHandSide, IExpr rightHandSide, boolean packageMode) {
final Object[] result = new Object[] { null, rightHandSide };
if (leftHandSide.isAST()) {
final ISymbol lhsSymbol = ((IAST) leftHandSide).topHead();
result[0] = lhsSymbol.putDownRule(ISymbol.RuleType.SET_DELAYED, false, leftHandSide, rightHandSide, packageMode);
return result;
}
if (leftHandSide.isSymbol()) {
final ISymbol lhsSymbol = (ISymbol) leftHandSide;
if (lhsSymbol.hasLocalVariableStack()) {
lhsSymbol.set(rightHandSide);
return result;
}
result[0] = lhsSymbol.putDownRule(ISymbol.RuleType.SET_DELAYED, true, leftHandSide, rightHandSide, packageMode);
return result;
}
throw new RuleCreationError(leftHandSide);
}
use of org.matheclipse.core.eval.exception.RuleCreationError in project symja_android_library by axkr.
the class Package method evaluate.
@Override
public IExpr evaluate(final IAST ast, EvalEngine engine) {
Validate.checkSize(ast, 4);
if (!(ast.arg1() instanceof IStringX) || !ast.arg2().isList() || !ast.arg3().isList()) {
throw new WrongNumberOfArguments(ast, 1, ast.size() - 1);
}
if (Config.SERVER_MODE) {
throw new RuleCreationError(null);
}
IAST symbols = (IAST) ast.arg2();
IAST list = (IAST) ast.arg3();
evalPackage(symbols, list, engine);
return F.Null;
}
Aggregations