Core syntax and data model

The first thing to learn about Detail is its data model. A value in Detail is called a detail. A detail is either an integer, an ordered pair, or a three-way value called a "blank."

The core syntax is a simple grammar that can express any detail. It is not that useful by itself, but it is a good subset for higher-level, more expressive syntaxes. It is also used extensively in this spec.

Core syntax

    body: *white detail *white
    detail: pair | integer | blank

    pair: '(' *white detail *(+white detail) *white ')'

    integer: (hex | decimal | text)
    decimal: '%' ('0' | (?('-') [1-9] *[0-9]))
    hex: '%' ':' ('0' | (?('-') [1-9a-f] *[0-9a-f]))
    text: +[a-z0-9]

    blank: yin | qi | yang
    yin: '.'
    qi: '~'
    yang: '_'

    white: ' ' | '\n'

Data model

A value in Detail is called a detail. Details come in one of three shapes (avoiding the word "type", which means too many things to too many people): pair, integer, or blank. A detail is flat if it's an integer or a blank.

A pair is an ordered pair of two details, called the head and tail. The core pair syntax nests right: (a b c d) is equivalent to (a (b (c d))). Also, (a) is a.

An integer is an integer of any size and either sign. The text integer syntax just encodes an ASCII string as an integer with the first byte low. For example, hello is equivalent to %:6f6c6c6568.

A blank is a ternary shape with no intrinsic semantics. The blank values are called yin (rhymes with "pin"), qi (pronounced "chee"), and yang (rhymes with "bang"). Conventionally, yin is true and yang is false.

A pair nested to the right is called a tuple. For example, (a b c d) is a 4-tuple. The tuple is a list if the last element in it is a blank (usually yin).