Expand description
Human-readable Crous text format: parser and pretty-printer.
§Crous Text Syntax (summary)
The Crous textual notation is a unique, deterministic syntax that maps 1:1 to the binary format. It is NOT a JSON clone — it has its own rules:
- Objects use
{ key: value; key2: value2; }with;as mandatory terminator. - Arrays use
[ value, value, value ]with,separator. - Strings are double-quoted:
"hello world". - Binary data uses
b64#<base64>;marker. - Integers: unsigned are bare digits, signed use
+or-prefix. - Floats use decimal point:
3.14,-2.718. - Null is
null, booleans aretrue/false. - Optional type annotations:
42::u32,"hello"::str. - Comments:
// line commentand/* block comment */.
§ABNF Grammar
document = value
value = null / boolean / integer / float / string / bytes
/ array / object
null = "null"
boolean = "true" / "false"
integer = [sign] 1*DIGIT [type-ann]
float = [sign] 1*DIGIT "." 1*DIGIT [exponent] [type-ann]
exponent = ("e" / "E") [sign] 1*DIGIT
sign = "+" / "-"
string = DQUOTE *char DQUOTE [type-ann]
bytes = "b64#" base64-data ";"
base64-data = *( ALPHA / DIGIT / "+" / "/" / "=" )
array = "[" [value *("," value)] "]"
object = "{" *field "}"
field = key ":" value ";"
key = identifier / string
identifier = (ALPHA / "_") *(ALPHA / DIGIT / "_")
type-ann = "::" type-name
type-name = identifier
comment = line-comment / block-comment
line-comment = "//" *(%x20-7E) LF
block-comment= "/*" *(comment-char) "*/"Functions§
- parse
- Parse a Crous text document into a
Value. - pretty_
print - Pretty-print a
Valuein canonical Crous text notation.