Table of Contents

About

We can create a language for key-value pairs that will allow us to specify how a key-value pair encoded string can be formatted. For instance, it is useful to know whether certain keys depend on other keys or values of other keys, which keys are optional and which are required, etc… This language is used by the Corrade scripted agent to describe the syntax of its commands.

Definitions

Here are the basic definitions of the syntax string:

Consequences (Lemmas)

Precedence of Operators

  1. Bracket symbols: [, ] and <, >
  2. Context symbol :
  3. Alternating symbol: |
  4. Comma: ,
  5. Key-value pair binding symbol: &
  6. Key and value separator: =

Examples

Here are some basic examples that are used to describe the syntax of commands.

Required and Optional Keys

In the following example:

<command=test>&[option=<BOOL>]

for each key-value pair:

This results in the possible commands:

Enumerators

In the following example:

<command=test>&[option=<BOOL[,BOOL...]>]

The command key is required and must be set to test and the optional option key must be set to a CSV string of booleans. The construct BOOL[,BOOL…] indicates one or more booleans.

This leads to the following generated commands:

Contexts

In the following example:

<command=<hello|bye>>&command=hello:<greeting=<STRING>>&command=bye:[greeting=<STRING>]

command is a required key with two possible required values, either:

Then for each of the two possible required values, either hello or bye that must be passed to the command key, we have the following context judgements:

Based on the above, the following commands can be generated:

The consequence being that the hello command requires a greeting but that greeting is optional for the bye command.

One can have multiple contexts, separated by a comma (,) for example:

<command=hello>&<join=<hello|hi>>&<part=<bye|ciao>>&join=hello,part=bye:<say=<STRING>>&join=hi,part=ciao:[say=<STRING>]

which reads the following way:

This leads to the following possible generated valid command strings:

Optional Keys

One frequently used construct in Corrade's command structure reads "agent by UUID or avatar by firstname and lastname" which means that you can refer to an agent by writing agent=UUID or you can refer to an agent by writing firstname=Mickey&lastname=Mouse. This meaning is encoded in the syntax as follows:

<command=kiss>&<agent=<UUID>|firstname=<STRING>&lastname=<STRING>>&[intensity=<INTEGER>]

which reads:

It is important to notice that the bracket operators such as < and > or [ and ] are of a higher precedence than the ampersand &.

Index