public class ShuntingYardDualStack extends ShuntingYard
ShuntingYardDualStack
class provides an implementation of the Shunting Yard algorithm using Dual Stacks.Modifier and Type | Field and Description |
---|---|
protected Stack<Operand> |
operandStack
Stack to hold the operands.
|
protected Stack<Operator> |
operatorStack
Stack to hold the operators.
|
Constructor and Description |
---|
ShuntingYardDualStack()
No-Argument Constructor.
|
Modifier and Type | Method and Description |
---|---|
double |
evaluate(String expr)
Method to evaluate an expression.
This method acts as the single point of access for expression evaluation. |
protected Operand |
evaluateExpr(String expr)
Method to evaluate the expression string and return the result as an operand.
|
protected void |
evaluateParenthesis()
Method to evaluate operators at the top of the operator stack until a left parenthesis is encountered.
|
protected void |
evaluateTOS()
Method to evaluate the operator at the top of the operator stack.
|
protected Operand evaluateExpr(String expr)
expr
- Expression stringprotected void evaluateTOS()
protected void evaluateParenthesis()
public double evaluate(String expr)
evaluate
in class ShuntingYard
expr
- Expression stringCopyright © 2019 Pratanu Mandal. All rights reserved.