public void parseRPN(Stack<String> stackRPN) throws ParseException {
        if (stackRPN.empty()) {
            return;
        }
        Stack<Evaluable> stackResult = new Stack<>();
        while (!stackRPN.empty()) {
            String token = stackRPN.pop();
            if (isNumber(token)) {
                stackResult.push(new Const(Integer.parseInt(token)));
            } else if (isVariable(token)) {
                stackResult.push(new Variable(token));
            } else if (isOperator(token)) {
                Evaluable a = stackResult.pop();
                Evaluable b = stackResult.pop();
                Evaluable result = new Const(0);
                switch (token) {
                    case "+":
                        result = new Sum(a, b);
                        break;
                    case "-":
                        result = new Subtract(b, a);
                        break;
                    case "*":
                        result = new Multiply(a, b);
                        break;
                    case "/":
                        result = new Division(b, a);
                        break;
                }
                stackResult.push(result);
            }
        }
        this.result = stackResult.pop();
    }