Speaking of the sub-object reference, this PR also introduces new alternative syntax for sub-object referencing that is more user friendly. You'll find it much easy to use, e.g. when finding an object in tree view.
Code: Select all
Code: Select all
There are more subtle changes introduced in this PR. The parsing of unit expression has been changed to eliminate the possibility of new unit breaking backward compatibility. Previously, the unit keyword is recognized inside lexical scanner. For example, the unit 'A' will make it impossible for the expression to refer to any object/property with that name. This is not a big problem if we fixed unit keywords. It will be a problem if we keep adding new units (which has happened recently in upstream), because existing expression may refer to some object/property with the now illegal names. This PR addressed this problem by interpreting unit keyword in runtime if there is ambiguity, and give object/property name higher priority over unit, so that existing expression continues to work even if it contains name references that clash with the new unit.
The parser now disambiguate unit reference like this,
* For an identifier immediately following a number, it will only be interpreted as unit, e.g. 1m, where 'm' will always be interpreted as meter.
* For any identifiers inside a bracket that immediately follows a number, they will only be interpreted as unit, e.g. 1(m/s)
* For any other occurrence of an identifier, it will always be treated just like an identifier, and resolved at runtime. If no object or property can be found by that name, it will be tried as unit. For example, 1/m can mean different thing if there is a property named 'm' or not. To refer to unit explicitly, use bracket, 1(1/m)