/
Syntax and types

Syntax and types

To use SIL like any other scripting language follow a few simple syntax rules.

General rules

  • All instructions end with a semicolon ;

  • Comments are introduced using //comment_until_end_of_line or /* comment */

Example
// single line comment /* this comment spans over multiple lines */

Types

Basic Types

SIL defines the following base types:

  • string - defines a string, example literal is "abc"

  • boolean - defines boolean values true and false

  • number - any numeric value

  • integer - a numeric value without a fractional component

  • byte - a byte

  • date - a date, like "2010-03-30"

  • interval - a time interval, like "2d 3h"

Important notes

  • interval - data type does not represent the working interval (i.e. 8h), but the full interval. When we created SIL™ we thought about if we should introduce a working interval type (i.e. 8h / day) but this would have certain undesired implications (how long is your workday? in France, for instance, Friday is only 6h). With our custom fields, it's a matter of interpretation of the interval, and we have functions to help you transform a 24h interval to a working interval, or you can simply write your own.

  • date - data type can be used to represent dates and date-times.

  • number - data type internal storage is represented only by real numbers (double). However, the language accepts for historical reasons type declarations as "real", "double", "float" (treating them as "number", of course).

  • integer (or int) - is actually a long in the traditional sense

Arrays

Multi-value (arrays) types are also supported and composed of the base type followed by the array symbols [ ]  for each dimension of the array type. This translates to the following being valid array types:

  • string[]

  • boolean[]

  • number[][]

  • integer[]

  • date[][][]

  • interval[]

  • Person[][] - where Person is a user-defined structure

Key-Value Arrays (Maps)

Arrays are actually maps where values are keyed by their position in the list, and so key-value arrays are declared the same as regular arrays.

Learn more about maps and the indexing operator.

Structures

The general syntax for defining a structure is:

struct <name> { <type> <fieldName>; }

Structures are defined by their name and pairs of field type and field name. A structure can have any number of fields. The type of each field can be a simple type, a user-defined structure (including the structure being defined) or arrays of these types.

Example:

struct Person { string id; string name;