Ziggy Scalar Values
Integers and floats
Numeric values in Ziggy can be either integers or floats. Both numeric values can have a negative sign in front of them and use underscores to group digits.
Integers
Integers can have the following prefixes to indicate a base different than 10:
0xfor base 160ofor base 80bfor base 2
Note: x, o, and b must be lowercase, while a - f hex digits can be both lower or uppercase.
Examples: 123, 0xffffff, 0xFF_FF_FF, 0o7_5_5, 0b01_01_01
Floats
Floats support exponential notation and can also be expressed in base 16. Base 10 floats use e as the exponent separator, while base 16 floats use p. Both letters can also be uppercase.
Base 10 examples: 123.0, 123_000.456_000, 123.0e+77, 123.0E+77
Base 16 examples: 0x103.70p-5, 0x103.70, 0x1234_5678.9ABC_CDEFp-10
Bools
true, false
Null
null
Bytes
Bytes in Ziggy are comparable to strings in other data languages with the main distinction that they don’t require you to encode valid Unicode codepoints, hence the name.
Applications that require valid Unicode (or any other data invariant) will have to perform those checks separately as needed.
To add quotes, newlines or other unprintable byte sequences to a Ziggy bytes literal, you can use escape sequences.
Escape sequences
\nnewline\rcarriage return\ttab\\backslash\'single quote\xNNhexadecimal 8-bit byte value (2 digits)\u{NNNNNN}hexadecimal Unicode code point UTF-8 encoded (1 or more digits)
Examples: "🧑🚀", "\x1B[?1000h gang", "lorem ipsum\ndolor sit", "h\x65llo world", "\xf0\x9f\x92\xaf"
Multiline bytes literals
When a byte value must encode multiline text, you can use multiline syntax to keep the text readable by humans.
Example:
\\This is a mulitline literal.
\\
\\Lorem ipsum something something.
\\Dolor sit something else.
Note that multiline literals don’t support escape sequences which makes them handy when you need a “raw string” to express things like regular expressions.
Lastly, multiline literals don’t include the last newline, so to have a trailing newline be part of your bytes, you will need to add an extra final empty line.
Enum literals
Enums literals represent one option out of a limited set. They start with a . followed by a simple identifier (a-zA-Z0-9_).
Examples: .foo, .bar, .foo_bar
Enum literals are the scalar counterpart to union literals, presented in the Container Values section. Together they make up the Ziggy Document syntax that maps to tagged unions in Ziggy Schema.