Containers

Letlang has 3 types of containers:

Tuples

Syntax

tuple_expression
( expression , ) ( expression , , )
Show source
tuple_expression
  = ("(" (expression ",")? ")")
  / ("(" expression ("," expression)* ","? ")")

Example

(1, 2);

Named tuples

Order in a named tuple MUST NOT matter.

Syntax

namedtuple_expression
{ namedtuple_pair , } { namedtuple_pair , , }
Show source
namedtuple_expression
  = ("{" (namedtuple_pair ",")? "}")
  / ("{" namedtuple_pair ("," namedtuple_pair)* ","? "}")
namedtuple_pair
identifier : expression
Show source
namedtuple_pair
  = identifier ":" expression
access_expression
expression . identifier
Show source
access_expression
  = expression "." identifier

Example

user := { name: "john", age: 42 };
"john" := user.name;

Lists

Syntax

list_expression
[ expression , ] [ expression , , ]
Show source
list_expression
  = ("[" (expression ",")? "]")
  / ("[" expression ("," expression)* ","? "]")
list_headtail_expression
[ expression , , | expression ]
Show source
list_headtail_expression
  = "[" expression ("," expression)* ","? "|" expression "]"

Example

l := [3, 4, 5];
l := [1, 2 | l];
[1, 2, 3, 4, 5] := l;