Search in sources :

Example 1 with Parser

use of org.matheclipse.parser.client.Parser in project symja_android_library by axkr.

the class PatternMatchingTestCase method setUp.

//	public void testSlotPatternMatching() {
//		checkPattern("b_.* #+c_.*#^2", "#-1*#^2", "");
//		checkPattern("b_.* #+c_.*#^2", "#+#^2", "[1, 1]");
//		checkPattern("a_. + b_.* #+c_.*#^2", "-1+#+#^2", "[-1, 1, 1]");
//	}
/**
	 * The JUnit setup method
	 */
protected void setUp() {
    try {
        // setup the evaluation engine (and bind to current thread)
        //			F.initSymbols();
        // EvalEngine.get();
        EvalEngine engine = new EvalEngine();
        EvalEngine.set(engine);
        engine.setSessionID("SpecialTestCase");
        engine.setRecursionLimit(256);
        engine.setIterationLimit(1024 * 1024);
        util = new EvalUtilities(engine, false, false);
        // setup a parser for the math expressions
        fParser = new Parser();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : EvalUtilities(org.matheclipse.core.eval.EvalUtilities) EvalEngine(org.matheclipse.core.eval.EvalEngine) Parser(org.matheclipse.parser.client.Parser)

Example 2 with Parser

use of org.matheclipse.parser.client.Parser in project symja_android_library by axkr.

the class ParserTestCase method testParser14.

public void testParser14() {
    try {
        Parser p = new Parser();
        ASTNode obj = p.parse("-a-b*c!!+d");
        assertEquals(obj.dependsOn("d"), true);
        assertEquals(obj.dependsOn("x"), false);
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals("", e.getMessage());
    }
}
Also used : ASTNode(org.matheclipse.parser.client.ast.ASTNode) Parser(org.matheclipse.parser.client.Parser)

Example 3 with Parser

use of org.matheclipse.parser.client.Parser in project symja_android_library by axkr.

the class ParserTestCase method testParser20.

public void testParser20() {
    try {
        Parser p = new Parser();
        ASTNode obj = p.parse("B[[;;, 2]]");
        assertEquals(obj.toString(), "Part(B, Span(1, All), 2)");
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals("", e.getMessage());
    }
}
Also used : ASTNode(org.matheclipse.parser.client.ast.ASTNode) Parser(org.matheclipse.parser.client.Parser)

Example 4 with Parser

use of org.matheclipse.parser.client.Parser in project symja_android_library by axkr.

the class ParserTestCase method testParser24.

public void testParser24() {
    try {
        Parser p = new Parser();
        ASTNode obj = p.parse("x'[t] == 10*(y[t] - x[t])");
        assertEquals(obj.toString(), "Equal(Derivative(1)[x][t], Times(10, Plus(y(t), Times(-1, x(t)))))");
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals("", e.getMessage());
    }
}
Also used : ASTNode(org.matheclipse.parser.client.ast.ASTNode) Parser(org.matheclipse.parser.client.Parser)

Example 5 with Parser

use of org.matheclipse.parser.client.Parser in project symja_android_library by axkr.

the class ParserTestCase method testParser12.

public void testParser12() {
    try {
        Parser p = new Parser();
        ASTNode obj = p.parse("-(Pi/4)");
        assertEquals(obj.toString(), "Times(-1, Times(1/4, Pi))");
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals("", e.getMessage());
    }
}
Also used : ASTNode(org.matheclipse.parser.client.ast.ASTNode) Parser(org.matheclipse.parser.client.Parser)

Aggregations

Parser (org.matheclipse.parser.client.Parser)40 ASTNode (org.matheclipse.parser.client.ast.ASTNode)32 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 EvalEngine (org.matheclipse.core.eval.EvalEngine)2 IExpr (org.matheclipse.core.interfaces.IExpr)2 FunctionNode (org.matheclipse.parser.client.ast.FunctionNode)2 BufferedReader (java.io.BufferedReader)1 StringWriter (java.io.StringWriter)1 CSVFormat (org.apache.commons.csv.CSVFormat)1 CSVRecord (org.apache.commons.csv.CSVRecord)1 AST2Expr (org.matheclipse.core.convert.AST2Expr)1 EvalUtilities (org.matheclipse.core.eval.EvalUtilities)1 TimeConstrainedEvaluator (org.matheclipse.core.eval.TimeConstrainedEvaluator)1 WrongNumberOfArguments (org.matheclipse.core.eval.exception.WrongNumberOfArguments)1 OutputFormFactory (org.matheclipse.core.form.output.OutputFormFactory)1 IAST (org.matheclipse.core.interfaces.IAST)1 IStringX (org.matheclipse.core.interfaces.IStringX)1