Skip to content



  • Feel free to skip this section if you have not written or dealt with XML mission scripts.
  • This page is about aspects that required some focused investigation toward the correct translation from TethysL to XML according to the LRAUV execution semantics.

Operator precedence in expressions

Consider the 'While' condition expression in the following fragment from the original Insert/Science.xml mission file:

<ReadData Strategy="MinError">
        <Arg Name="EnabledNeilBrown"/>
        <Or><Arg Name="EnabledSeabird"/></Or>
        <And><Arg Name="UpwardDerivativeOfTemperatureActive"/></And>

Syntactically, this expression looks rather atypical: each of the occurring <Or> and <And> elements only contains a single argument. So, what are the actual operands in each case?

In pseudo-code, the expression above can be directly transliterated as:

EnabledNeilBrown or EnabledSeabird and UpwardDerivativeOfTemperatureActive

Does LRAUV follow the general programming language convention of and having higher precedence than or for evaluation purposes?

According to the following comment in ValueClause.cpp's ValueClause::Instance method, it looks like LRAUV basically performs a left-to-right evaluation without specific attention to operator precedence:

// Order of nodes is LHS [operator RHS0 [operator RHS1 [operator RHS2 ...
// Deal with this as (((LHS operator RHS0) operator RHS1 ) operator RHS2 )

The ValueClause::toString() method also suggests this left-to-right scheme.1

TethysL is currently capturing operator precedence in expressions, including support for any desired parenthesization. So, we need to verify and possibly adjust the conversion to XML so as to preserve the intended evaluation semantics.

  1. Possible revision. In general, to accommodate for unambiguous evaluation order and operator arguments, the XML Schema (along with corresponding LRAUV execution logic) should have probably captured expressions in a more standard way. For example, the case above would be expressed as follows, which, in particular, gives a clear indication of the operands for each operator:

        <Arg Name="EnabledNeilBrown"/>
          <Arg Name="EnabledSeabird"/>
          <Arg Name="UpwardDerivativeOfTemperatureActive"/>