
// CS410, Summer 1998
// HW2 

// Calculator.java
// The main file for homework 2

// This is the file with holes for you.

// This file will not compile as given.  The easiest fix is to comment
// out the methods you haven't written yet.

import java.io.*;

class Calculator {

	static int postfixEval(TokenReader in) 
			throws	CalculatorDivideByZeroException, 
					CalculatorIllegalInputException {
			// make me evaluate postfix
	}

	static int prefixEval(TokenReader in) 
			throws	CalculatorDivideByZeroException, 
					CalculatorIllegalInputException {
		// make me evaluate prefix
	}

	static InfixTree prefixToInfix(TokenReader in) 
			throws CalculatorIllegalInputException {
		// make me convert prefix to infix
	}
	
	static int infixEval(InfixTree t) 
			throws CalculatorDivideByZeroException {
		// make me evaluate infix
	}

	static String infixString(InfixTree t) {
		// make me convert infix to a String
	}

	// static String infixStringEC(InfixTree t) {
		// make me convert infix to a String without unnecessary parentheses
		// (extra credit)
	// }


	// no need to modify main, but you are welcome to.
	public static void main (String [] argv) throws IOException {
		// Make sure input arguments are legit.
		if ((argv.length != 2)
			|| (!argv[0].equals("pre") && !argv[0].equals("post"))) {
			System.err.println("Bad input arguments to Calculator. " +
				"Should be: \"Calculator pre filename\" or " +
				"\"Calculator post filename\" ");
			System.in.read();
			return;
		}
		
		// open the file and test the methods with it
		try {
			String kind = argv[0];
			String fname = argv[1];
			if (kind.equals("post")) {
				System.out.println("Postfix Evaluation of " + fname + ":");
//				System.out.println(postfixEval(new TokenReader(fname)));
			}
			else if (kind.equals("pre")) {
				System.out.println("Prefix Evaluation of " + fname + ":");
//				System.out.println(prefixEval(new TokenReader(fname)));
//				InfixTree t = prefixToInfix(new TokenReader(fname));
				System.out.println("Infix of Expression:");
//				System.out.println(infixString(t));
				System.out.println("and without redundant parentheses:");
//				System.out.println(infixStringEC(t));
				System.out.println("Evaluation of Infix:");
//				System.out.println(infixEval(t));
			}
		} catch (Exception e) {
			System.err.println(e);
		}
		// Keep the window from disappearing.
		System.in.read();
	}
}
