aboutsummaryrefslogtreecommitdiff
path: root/examples/zon-examples/full-types.zon
blob: 5a06044ef3dd21546ee718fe59ea727f3a013dfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// ZON full-type showcase — exercises all value forms the ZON grammar supports.
// Open in Nova to verify syntax highlighting across every literal kind.
.{
    // String (double-quoted)
    .name = "nova-zig-full",

    // Integers — decimal, hex, octal, binary, with digit separators
    .decimal = 42,
    .hex = 0xFF,
    .octal = 0o77,
    .binary = 0b1010_1010,
    .large = 1_000_000,

    // Floats
    .pi = 3.14159,
    .scientific = 1.5e10,
    .negative_float = -0.001,

    // Booleans
    .flag_on = true,
    .flag_off = false,

    // Null
    .optional = null,

    // Enum tag / identifier literal (dot-prefixed)
    .level = .info,
    .theme = .solarized,

    // Negative integer
    .offset = -7,

    // Nested struct
    .metadata = .{
        .author = "David",
        .year = 2025,
        .prerelease = false,
    },

    // Array of strings
    .targets = .{
        "x86_64-linux",
        "aarch64-macos",
        "wasm32-wasi",
    },

    // Array of nested structs
    .rules = .{
        .{ .name = "lint", .enabled = true },
        .{ .name = "format", .enabled = false },
        .{ .name = "test", .enabled = true },
    },

    // Deeply nested
    .config = .{
        .server = .{
            .host = "localhost",
            .port = 8080,
            .tls = .{
                .enabled = false,
                .cert = null,
            },
        },
    },

    // Unicode string
    .label = "Zig \u{2744} Nova",

    // Empty struct
    .empty = .{},

    // Empty array
    .no_items = .{},
}