Schema & Data
The most important ASUN idea is that schema describes structure once, and data only supplies ordered values.
The Split
Schema:
{name@str, age@int, active@bool}Data:
(Alice, 30, true)Combined:
{name@str, age@int, active@bool}:(Alice, 30, true)For a list, write the schema once and then multiple tuples:
[{name@str, age@int}]:
(Alice, 30),
(Bob, 25)Schema Rules
Each field uses @ as the field binding marker. A scalar field may be written as:
name
name@typeScalar hint names are only:
intfloatstrbool
Complex fields use the same @ as a required structural binding:
@{...}nested struct@[type]array@[{...}]array of structs
Examples:
{profile@{id@int, name@str}}
{tags@[str]}
{attrs@[{key@str, value@str}]}This means:
nameandname@strproduce the same structural layoutaddress@{...}andtags@[...]cannot drop@, because it binds the field to the nested schema
Field Names
Plain field names work for simple identifiers:
{id, name, active}Quoted field names are required when a field name contains spaces, starts with digits, or contains syntax characters:
{"id uuid"@int, "65"@bool, "{}[]@\""@str}Data Rules
Data is positional, not keyed. The first value matches the first field, the second value matches the second field, and so on.
Nested struct data uses nested tuples:
{address@{city@str, zip@str}}:((Berlin, 10115))Arrays use square brackets:
{tags@[str]}:([rust, go, zig])An empty slot represents null / missing:
{id@int, score@float}:(1, )What ASUN Does Not Do
Current ASUN text does not use inline object literals in the data section:
{user@{id@int}}:({id: 1}) // not current ASUNWrite key-value collections as entry lists:
{attrs@[{key@str, value@str}]}:([(lang, zig), (tier, prod)])Short Grammar Summary
single = schema ":" tuple
slice = "[" schema "]" ":" rows
schema = "{" fields "}"
field = name ["@" type]
type = "int" | "float" | "str" | "bool" | schema | "[" type "]"
rows = tuple ("," tuple)*
tuple = "(" values ")"
values = value ("," value)*
value = scalar | tuple | "[" values "]" | ""See the full Syntax Reference for string, escaping, whitespace, and comment rules.