The .prisma ASCII format

The ASCII encoding

.prisma is the human-authorable encoding of a Document: a USDA-flavoured ASCII format that is diff-clean and stable, the form you write by hand and commit to git. It is one of Core's two native encodings, alongside the .prism binary. They carry the same Document and convert losslessly either way.

Every file begins with a version header, then nests Elements with braces:

#prisma 4.0
def group "world" {
    def object "ball" {
        float3 position = (0, 1, 0)
        float  radius   = 1.5
        float3 albedo   = (1, 1, 1)
        connect albedo  = </world/mat.out>
    }
}

The grammar, briefly

Stable and diff-clean

The serializer sorts deterministically, so two saves of the same Document produce byte-identical files and a real change produces a small, readable diff. That is a deliberate property: .prisma is meant to live in version control, be reviewed in a pull request, and merge sanely. Values are self-describing (the dtype and shape travel with the data), so a .prisma file carries everything a reader needs, with no external schema.

Parsing, with located errors

deserialize accepts an optional ParseError* that is filled with a file-absolute line:column and a message on failure, the same diagnosis the CLI's check surfaces:

ParseError err;
auto doc = deserialize(text, &err);
if (!doc) fprintf(stderr, "%zu:%zu: %s\n", err.line, err.column, err.message.c_str());
$ kinogaki check broken.prisma
broken.prisma:4:18: error: invalid value for its declared type

Encoding is detected by content, so the parser reads a file by its leading bytes whatever its suffix. When you want compactness or large numeric arrays in place of readability, reach for the binary format.