// Path: Calculator/src/com/digipom/android/library/evaluator/exception/ParseException.java
// public class ParseException extends Exception {
// 	private static final long serialVersionUID = 1L;
// 	
// 	public ParseException() {
// 		super();
// 	}
// 
// 	public ParseException(String detailMessage, Throwable throwable) {
// 		super(detailMessage, throwable);
// 	}
// 
// 	public ParseException(String detailMessage) {
// 		super(detailMessage);
// 	}
// 
// 	public ParseException(Throwable throwable) {
// 		super(throwable);
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/BigDecimalNumberLiteral.java
// public class BigDecimalNumberLiteral extends NumberLiteral {
// 	public final BigDecimal value;
// 
// 	public BigDecimalNumberLiteral(BigDecimal value) {
// 		this.value = value;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return value.toString();
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/DoubleNumberLiteral.java
// public class DoubleNumberLiteral extends NumberLiteral {
// 	public final double value;
// 
// 	public DoubleNumberLiteral(double value) {
// 		this.value = value;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return String.valueOf(value);
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/FloatNumberLiteral.java
// public class FloatNumberLiteral extends NumberLiteral {
// 	public final float value;
// 
// 	public FloatNumberLiteral(float value) {
// 		this.value = value;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return String.valueOf(value);
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/Identifier.java
// public class Identifier implements Token {
// 	public final String name;
// 	public float value;
// 
// 	public Identifier(String name) {
// 		this.name = name;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return name + "=" + value;
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/NumberLiteral.java
// public abstract class NumberLiteral implements Token {
// 
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/Operator.java
// public enum Operator implements Token {
// 	ADD(0, LEFT), SUBTRACT(0, LEFT), MULTIPLY(1, LEFT), DIVIDE(1, LEFT), NEGATION(2, RIGHT), POWER(3, RIGHT);	
// 
// 	public static enum Associativity {
// 		LEFT, RIGHT
// 	}
// 
// 	public final int precedence;
// 	public final Associativity associativity;
// 
// 	private Operator(int precedence, Associativity associativity) {
// 		this.precedence = precedence;
// 		this.associativity = associativity;
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		if (this == ADD) {
// 			return "+";
// 		} else if (this == SUBTRACT || this == NEGATION) {
// 			return "-";
// 		} else if (this == MULTIPLY) {
// 			return "*";
// 		} else if (this == DIVIDE) {
// 			return "/";
// 		} else {
// 			return "^";
// 		}
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/PredefinedFunction.java
// public enum PredefinedFunction implements Token {
// 	POW, ABS, SIN, COS, TAN, LN, SQRT;
// 	
// 	@Override
// 	public String toString() {
// 		return name().toLowerCase();
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/Token.java
// public interface Token {
// 	public static final Token EOF = new Token() {};
// }


import java.math.BigDecimal;
import java.util.List;
import com.digipom.android.library.evaluator.exception.ParseException;
import com.digipom.android.library.evaluator.lexer.BigDecimalNumberLiteral;
import com.digipom.android.library.evaluator.lexer.DoubleNumberLiteral;
import com.digipom.android.library.evaluator.lexer.FloatNumberLiteral;
import com.digipom.android.library.evaluator.lexer.Identifier;
import com.digipom.android.library.evaluator.lexer.NumberLiteral;
import com.digipom.android.library.evaluator.lexer.Operator;
import com.digipom.android.library.evaluator.lexer.PredefinedFunction;
import com.digipom.android.library.evaluator.lexer.Token;
//   Copyright 2012 Digipom Inc.
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.

package com.digipom.android.library.evaluator;



public abstract class PostfixEvaluator {
	static class FlatToken {
		static final FlatToken UNDEFINED = new FlatToken();

		static final int TYPE_UNDEFINED = 0;
		static final int TYPE_IDENTIFIER = 1;
		static final int TYPE_NUMBER_LITERAL = 2;
// Path: Calculator/src/com/digipom/android/library/evaluator/exception/ParseException.java
// public class ParseException extends Exception {
// 	private static final long serialVersionUID = 1L;
// 	
// 	public ParseException() {
// 		super();
// 	}
// 
// 	public ParseException(String detailMessage, Throwable throwable) {
// 		super(detailMessage, throwable);
// 	}
// 
// 	public ParseException(String detailMessage) {
// 		super(detailMessage);
// 	}
// 
// 	public ParseException(Throwable throwable) {
// 		super(throwable);
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/BigDecimalNumberLiteral.java
// public class BigDecimalNumberLiteral extends NumberLiteral {
// 	public final BigDecimal value;
// 
// 	public BigDecimalNumberLiteral(BigDecimal value) {
// 		this.value = value;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return value.toString();
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/DoubleNumberLiteral.java
// public class DoubleNumberLiteral extends NumberLiteral {
// 	public final double value;
// 
// 	public DoubleNumberLiteral(double value) {
// 		this.value = value;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return String.valueOf(value);
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/FloatNumberLiteral.java
// public class FloatNumberLiteral extends NumberLiteral {
// 	public final float value;
// 
// 	public FloatNumberLiteral(float value) {
// 		this.value = value;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return String.valueOf(value);
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/Identifier.java
// public class Identifier implements Token {
// 	public final String name;
// 	public float value;
// 
// 	public Identifier(String name) {
// 		this.name = name;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return name + "=" + value;
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/NumberLiteral.java
// public abstract class NumberLiteral implements Token {
// 
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/Operator.java
// public enum Operator implements Token {
// 	ADD(0, LEFT), SUBTRACT(0, LEFT), MULTIPLY(1, LEFT), DIVIDE(1, LEFT), NEGATION(2, RIGHT), POWER(3, RIGHT);	
// 
// 	public static enum Associativity {
// 		LEFT, RIGHT
// 	}
// 
// 	public final int precedence;
// 	public final Associativity associativity;
// 
// 	private Operator(int precedence, Associativity associativity) {
// 		this.precedence = precedence;
// 		this.associativity = associativity;
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		if (this == ADD) {
// 			return "+";
// 		} else if (this == SUBTRACT || this == NEGATION) {
// 			return "-";
// 		} else if (this == MULTIPLY) {
// 			return "*";
// 		} else if (this == DIVIDE) {
// 			return "/";
// 		} else {
// 			return "^";
// 		}
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/PredefinedFunction.java
// public enum PredefinedFunction implements Token {
// 	POW, ABS, SIN, COS, TAN, LN, SQRT;
// 	
// 	@Override
// 	public String toString() {
// 		return name().toLowerCase();
// 	}
// }
// 
// Path: Calculator/src/com/digipom/android/library/evaluator/lexer/Token.java
// public interface Token {
// 	public static final Token EOF = new Token() {};
// }


// Path: Calculator/src/com/digipom/android/library/evaluator/PostfixEvaluator.java
import java.math.BigDecimal;
import java.util.List;
import com.digipom.android.library.evaluator.exception.ParseException;
import com.digipom.android.library.evaluator.lexer.BigDecimalNumberLiteral;
import com.digipom.android.library.evaluator.lexer.DoubleNumberLiteral;
import com.digipom.android.library.evaluator.lexer.FloatNumberLiteral;
import com.digipom.android.library.evaluator.lexer.Identifier;
import com.digipom.android.library.evaluator.lexer.NumberLiteral;
import com.digipom.android.library.evaluator.lexer.Operator;
import com.digipom.android.library.evaluator.lexer.PredefinedFunction;
import com.digipom.android.library.evaluator.lexer.Token;

//   Copyright 2012 Digipom Inc.
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.

package com.digipom.android.library.evaluator;



public abstract class PostfixEvaluator {
	static class FlatToken {
		static final FlatToken UNDEFINED = new FlatToken();

		static final int TYPE_UNDEFINED = 0;
		static final int TYPE_IDENTIFIER = 1;
		static final int TYPE_NUMBER_LITERAL = 2;
		static final int TYPE_OPERATOR = 3;