diff options
Diffstat (limited to 'examples/zon-examples')
| -rw-r--r-- | examples/zon-examples/full-types.zon | 74 | ||||
| -rw-r--r-- | examples/zon-examples/invalid.zon | 12 | ||||
| -rw-r--r-- | examples/zon-examples/minimal.zon | 1 |
3 files changed, 87 insertions, 0 deletions
diff --git a/examples/zon-examples/full-types.zon b/examples/zon-examples/full-types.zon new file mode 100644 index 0000000..5a06044 --- /dev/null +++ b/examples/zon-examples/full-types.zon @@ -0,0 +1,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 = .{}, +} diff --git a/examples/zon-examples/invalid.zon b/examples/zon-examples/invalid.zon new file mode 100644 index 0000000..e588d73 --- /dev/null +++ b/examples/zon-examples/invalid.zon @@ -0,0 +1,12 @@ +// INVALID ZON — used to test error reporting on .zon files. +// +// ZON struct fields must begin with a dot followed by an identifier. +// The bare key `name` on line 8 (no leading dot) is invalid syntax. +// Any tool that parses this file (ZLS, zig build, zig fmt) should +// report an error around that line, exercising the issue matcher on +// non-.zig source files. +.{ + name = "missing-dot", + .value = 1, + .ok = true, +} diff --git a/examples/zon-examples/minimal.zon b/examples/zon-examples/minimal.zon new file mode 100644 index 0000000..47c47bc --- /dev/null +++ b/examples/zon-examples/minimal.zon @@ -0,0 +1 @@ +.{} |
