Otter Documentation

Formal Grammar

OtterScript Banner

The following formal grammar defines a valid OtterScript using a BNF-like convention. This guide may be useful for writing syntax hilighters or script validators. See the formal specification to learn how these specifically behave.

Grammar Elements

The grammar refers to the following elements.

any_name
namespace
operation_name
param_name
template_name
No more than fifty characters: numbers (0-9), upper- and lower-case letters (a-Z), dashes (-), and underscores (_); must start with a letter, and may not start or end with a dash or underscore
async_token
lock_token
No more than fifty characters: numbers (0-9), upper- and lower-case letters (a-Z); must start with a letter.
template_param_name A variable type identifier ($, @, or %) immediately followed by any_name
context_type Either server, role, deployable, or directory
param_default An implicit or quoted string
comment See Comments & Descriptions
variable_expression A variable type identifier ($, @, or %) immediately followed by one of:
  • simple name - follows same rules as any_name
  • explicit name - a left-curly brace ({), followed by of characters with the same rules as any_name but that also allow spaces, followed by a right-curly brace (})
literal_expression a scalar_expression, vector_expression, or map_expression
scalar_expression a string; see Strings and Literals
indexed_expression A variable_expression for a vector (@) or map (%) type, immediately followed one of:
  • left bracket ([), scalar_expression, then right bracket (])
  • dot (.) then scalar_expression
vector_expression one of:
  • a variable_expression for a vector (@) type, or a
  • a @ character followed by left-parens ((), and any number of literal_expression delimeted with commas (,), followed by a right-parens ())
map_expression one of:
  • a variable_expression for a map (%) type, or a
  • a % character followed by left-parens ((), and any number of key-values pairs delimeted with commas (,), followed by a right-parens ()). A key-value pair consists of any_name, followed by a colon (:), followed by a literal_expression

Grammar Conventions

The following conventions are used to describe OtterScript's grammar, and are used in documentation and examples.

<label> ::= The name for a block of syntax. This convention is used to group and label sections of lengthy syntax or a unit of syntax that can be used in more than one location within a statement. Each location in which the block of syntax can be used is indicated with the label enclosed in chevrons: <label>.
text Undecorated text is an OtterScript keyword.
( ) (parens) Syntactical grouping for lists and optional items. Do not type the parens.
[,...n] Indicates the preceding item can be repeated n number of times. The occurrences are separated by commas.
[...n] Indicates the preceding item can be repeated n number of times. The occurrences are separated by blanks.
[ ] (brackets) Optional syntax items. Do not type the brackets.
| (vertical bar) Separates syntax items enclosed in brackets or braces. You can use only one of the items.
" " (quotes) Required syntax item, used for parens, brackets, etc. Do not type the quotes.
/ / (slashes) Required grammar element.