package org.lvcp.eepperly.main;

import org.lvcp.eepperly.interpreter.LispParser;
import org.lvcp.eepperly.interpreter.LispTokenizer;
import org.lvcp.eepperly.interpreter.ExprCompiler;

import java.util.Scanner;

/**
 * Created by eepperly16 on 12/14/15.
 */
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String line = scan.nextLine();
		System.out.println(ExprCompiler.INSTANCE.compile(LispParser.INSTANCE.parse(LispTokenizer.INSTANCE.tokenize(line))));
	}
}

@@ -26,16 +26,106 @@
 .main;%0A%0A
+import org.lvcp.eepperly.exception.ExprTypeException;%0Aimport org.lvcp.eepperly.expr.Expr;%0A
 import o
@@ -268,16 +268,148 @@
 mpiler;%0A
+import org.lvcp.eepperly.simplify.AbstractSimplifier;%0Aimport org.lvcp.eepperly.simplify.DefaultSimplifier;%0A%0Aimport java.util.Random;
 %0Aimport 
@@ -536,16 +536,124 @@
 args) %7B%0A
+%09%09Expr expr = Expr.ZERO;%0A%09%09Random rand = new Random();%0A%09%09AbstractSimplifier simp = new DefaultSimplifier();%0A
 %09%09Scanne
@@ -685,16 +685,34 @@
 em.in);%0A
+%09%09while (true) %7B%0A%09
 %09%09String
@@ -742,124 +742,945 @@
 ;%0A%09%09
-System.out.println(ExprCompiler.INSTANCE.compile(LispParser.INSTANCE.parse(LispTokenizer.INSTANCE.tokenize(line))));
+%09String strippedLine = line.replaceAll(%22%5C%5Cs+%22,%22%22).toLowerCase();%0A%09%09%09switch (strippedLine)%7B%0A%09%09%09%09case %22simplify%22:%0A%09%09%09%09%09try %7B%0A%09%09%09%09%09%09expr = expr.simplify(simp);%0A%09%09%09%09%09%09System.out.println(expr);%0A%09%09%09%09%09%7D catch (ExprTypeException ex)%7B%0A%09%09%09%09%09%09ex.printStackTrace();%0A%09%09%09%09%09%7D%0A%09%09%09%09%09break;%0A%09%09%09%09case %22zero%22:%0A%09%09%09%09%09try %7B%0A%09%09%09%09%09%09System.out.println(expr.findZero(3 * rand.nextDouble() + 0.05));%0A%09%09%09%09%09%7D catch (Exception ex)%7B%0A%09%09%09%09%09%09ex.printStackTrace();%0A%09%09%09%09%09%7D%0A%09%09%09%09%09break;%0A%09%09%09%09case %22differentiate%22:%0A%09%09%09%09%09try%7B%0A%09%09%09%09%09%09expr = expr.differentiate(Expr.getOneElementInSet(expr.getVariables())).simplify(simp);%0A%09%09%09%09%09%09System.out.println(expr);%0A%09%09%09%09%09%7D catch (Exception ex)%7B%0A%09%09%09%09%09%09ex.printStackTrace();%0A%09%09%09%09%09%7D%0A%09%09%09%09%09break;%0A%09%09%09%09default:%0A%09%09%09%09%09try %7B%0A%09%09%09%09%09%09expr = ExprCompiler.INSTANCE.compile(LispParser.INSTANCE.parse(LispTokenizer.INSTANCE.tokenize(line)));%0A%09%09%09%09%09%09System.out.println(expr);%0A%09%09%09%09%09%7D catch (Exception ex)%7B%0A%09%09%09%09%09%09ex.printStackTrace();%0A%09%09%09%09%09%7D%0A%09%09%09%09%09break;%0A%09%09%09%7D%0A%0A%09%09%7D
 %0A%09%7D%0A

Make simple user interface