Remix.run Logo
rgovostes 20 hours ago

There is a perfectly cromulent grammar for a unit-aware calculator:

    <expression without units> [<unit> [in <unit>]]
    <expression with units> [in <unit>]
"1+2 feet in meters" and "1 foot + 1 meter" are both unambiguous. There is no order of operations in terms of how the units bind. The expression "1 foot + 1" is appropriately invalid.

Of course the appropriate care must be paid to interpreting "in" correctly as either a unit or a keyword.