1 8 9 package org.lsmp.djepExamples; 10 import org.nfunk.jep.*; 11 import org.lsmp.djep.xjep.*; 12 16 public class PrintExample { 17 18 public static void main(String [] args) { 19 XJep j = new XJep(); 20 j.addStandardConstants(); 21 j.addStandardFunctions(); 22 j.addComplex(); 23 j.setAllowUndeclared(true); 24 j.setImplicitMul(true); 25 j.setAllowAssignment(true); 26 27 try 28 { 29 Node node = j.parse("a*b+c*(d+sin(x))"); 31 j.println(node); 33 String str = j.toString(node); 35 System.out.println("String is '"+str+"'"); 36 j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,true); 37 j.println(node); 38 39 j.getPrintVisitor().setMode(PrintVisitor.FULL_BRACKET,false); 40 Node node2=j.parse("1*x^1+0"); 41 j.println(node2); 42 Node simp=j.simplify(node2); 43 j.println(simp); 44 45 } 46 catch(ParseException e) { System.out.println("Parse error"); } 47 } 48 } 49 | Popular Tags |