protected Value findValue(String str, boolean sign) throws ParseException
    {
        try
        {
            Number number = new Number(str, sign);
            length += number.length();
            return number;
        }
        catch (ParseException e)
        {
            try
            {
                Brackets brackets = new Brackets(str, sign);
                length += brackets.length();
                return brackets;
            }
            catch (ParseException exc)
            {
            	try
            	{
	                Function function = new Function(str, sign);
	                length += function.length();
	                return function;
            	}
	            catch (ParseException ex)
	            {
	                if (ex.getMessage().equals("number") || ex.getMessage().equals("(") || ex.getMessage().equals("function"))
	                {
	                    throw new ParseException("Number, opening bracket or function expected but not found", ex.getErrorOffset());
	                }
	                else if (ex.getMessage().equals("operator") || ex.getMessage().equals(")"))
	                {
	                    throw new ParseException("Operator or closing bracket expected but not found", ex.getErrorOffset());
	                }
	                else throw ex;
	            }
	        }
        }
    }