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
Ziggy supports standard float notation and special float values:
123.0,123_000.456_000,123.0e77,123.0E+77nan,inf,-inf
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)\uNNNNhexadecimal Unicode code point UTF-8 encoded (4 digits)
JSON-compatible escape sequences
These sequences are supported in order to make Ziggy a JSON superset.
\/slash\bbackspace\fform feed
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.
Multiline bytes literals support tab characters.
\\import math
\\
\\def main():
\\ print("this line is indented with a tab")
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.