class ExtendedParser extends BaseParser {

    protected final float readFactor() throws ParserException {
        if (Character.isDigit(peek())) {
            return readNumber();
        } else if (Character.isAlphabetic(peek())) {
            StringBuilder builder = new StringBuilder();
            while (available() && (Character.isAlphabetic(peek()) || peek() == '_')) {
                builder.append(pop());
            }
            String variableName = builder.toString();
            
            if (variables.containsKey(variableName)) {
                return variables.get(variableName);
            } else {
                die("Unknown variable");
                return 0;
            }
        } else if (peek() == '(') {
            check('(');
            skipWhitespaces();
            float expression = readExpression();
            skipWhitespaces();
            check(')');
            return expression;
        } else if (peek() == '+') {
            check('+');
            return readFactor();
        } else if (peek() == '-') {
            check('-');
            return -readFactor();
        } else {
            die("Expected mathematical expression.");
            return 0;
        }
    }

    public  ExtendedParser(String toParse);

}