Skip to content

TethysL Syntax Extensions

TethysL is modeled after the Tethys XML schemas, so most of the language maps one-to-one to the corresponding XML elements. On top of that, TethysL offers a few syntax extensions that have no direct XML counterpart. They address a common situation in mission scripts: a group of elements that differ only by a number, for example, waypoints Lat1, Lon1, Lat2, Lon2, ..., and the legs Leg1, Leg2, ... that use them. Writing (and maintaining) such elements by hand is tedious and error-prone; the extensions let you write them once.

The extensions are resolved at compile time. The XML generated from a .tl file contains the corresponding expanded elements (e.g., Lat1, Lat2, ..., Leg1, Leg2, ...), so, from the point of view of the vehicle, there is no difference with an equivalent mission written without the extensions.

Tip

For existing .tl scripts that may benefit from these extensions, you can use the Lint feature (the CLI lint command, or the corresponding command in the VS Code Extension) to identify candidate places for use.

The extensions

  • Array: define a sequence of arguments or outputs, e.g., Lat[1..10].
  • Macro: generate a sequence of aggregates, e.g., Leg1, ..., Leg10.
  • Const: name the numbers used in the above, e.g., const $NUM_WAYPOINTS = 10.
  • Interpolation (PREVIEW): use the constants and macro variables within descriptions and strings, e.g., "Leg $j of $NUM_LEGS".

A typical mission combines the three:

mission Example {
  const $N = 4

  arguments {
    Lat[1..$N] = NaN degree
    Lon[1..$N] = NaN degree
  }

  macro $k = 1..$N {
    aggregate Wpt$k {
      run in sequence
      behavior Guidance:Waypoint {
        run in sequence
        set latitude = Lat[$k]
        set longitude = Lon[$k]
      }
    }
  }
}