backport (dpvc): Abstracted the NumberWithUnits to a more general
ObjectWithUnits and moved the FormulaWithUnits to this file as well,
since most of the code is common. Although, strictly speaking,
FormulaWithUnits is not legacy code, since the general object-with-units
is here, it will be easier to maintain FormulaWithUnits here as well.
When the Parser gets a real units class, all of this can be removed.
Also fixed the unit lookup code to use the actual names from the Units
library, so we can now be more accurate about determining the extent
of the units, and can handle things like '5 kg m / s' now. In the
case of ambiguous formulas with units, e.g., '5m kg' where m is a
variable, use '5*m kg' or '(5m) kg'.