Shorthand Script Syntax

It is possible to write SMACHA scripts in shorthand syntax in order to increase script brevity. The Parser module provides two methods, smacha.parser.Parser.sub_longhand() and smacha.parser.Parser.sub_shorthand() for converting scripts back and forth between the longhand and shorthand formats.

Shorthand Variable Names

Core variable names may be abbreviated in shorthand syntax as follows:

  • name: n,
  • manifest: m,
  • node_name: nn,
  • template: T,
  • script: S,
  • outcomes: o,
  • states: s,
  • params: p,
  • userdata: ud,
  • input_keys: ik,
  • output_keys: ok,
  • remapping: r,
  • transitions: t,
  • default_outcome: do,
  • outcome_map: om,
  • callbacks: cb.

Example usage of these abbreviations is provided in the SMACHA documentation introduction, as well as in numerous test scripts provided in the test/smacha_scripts/smacha_test_examples folder of the smacha package

Shorthand Parameter Insertion

Parameter insertions can also be abbreviated using shorthand syntax. For example, if the script parameters subject, verb and object contained the values I, writing and documentation respectively, then we can form the construction

[[[subject]], 'love', [[verb]], [[object]]]

using shorthand syntax, instead of

[[params, subject], 'love', [params, verb], [params, object]]

in longhand syntax, both of which would be parsed as I love writing documentation.