For the complete documentation index, see llms.txt. This page is also available as Markdown.

Formal Grammar (EBNF)

The grammar of Internet Object in EBNF.

This appendix gives the grammar of Internet Object in EBNF. It is the normative reference for document structure; the prose chapters explain semantics. Lexical rules (whitespace, comments, literals) are listed at the end.

Notation: = defines a rule, | alternation, [ ] optional, { } zero-or-more, ( ) grouping, "…" a literal. Whitespace and comments may appear between tokens unless a rule states otherwise.

Document

document        = [ header "---" ] section { sectionBreak section }
                | value ;                         (* a bare, header-less value/object *)

header          = { definition } ;
section         = [ sectionTag ] ( collection | object ) ;
sectionBreak    = "---" [ sectionTag ] ;
sectionTag      = sectionName [ ":" schemaRef ]    (* e.g.  employee : $employee *)
                | schemaRef ;                      (* e.g.  $employee *)

Header definitions

definition      = "~" key ":" defValue ;
key             = metaKey | variableKey | refKey ;
metaKey         = name ;                            (* metadata *)
variableKey     = "@" name ;                        (* value variable *)
refKey          = "$" name ;                        (* schema/type reference *)
defValue        = value | schema ;
schemaRef       = "$" name ;

Collections and records

Objects and arrays

A member's value may be absent, which is how an empty position is written: {p, , q} holds three members, the middle one carrying no value. A writer is required to emit this form when a positional member is skipped, so a grammar that demanded a value here would reject conformant writer output.

An array has no such production: valueList requires a value between commas, so [a,,c] is not an array with a hole — it is an error (unexpected-token). Objects bind members by position and therefore need to express a gap; arrays do not.

The optional trailing comma in memberList closes the list; it does not add an empty final position. {a, b,} holds two members, not three.

Values

Schema (MemberDef and SchemaDef)

Lexical

sectionName is narrower than name, and it is the one name in the format with no quoted form — the separator line runs to the end of the line, so nothing bounds the name. The rule is anchored on purpose: a parser must not match a prefix and leave the remainder to fail later, or --- a,b: $x would silently become a section named a. See Data Sections.

This grammar is a working draft for the 1.0 specification. Edge cases (precise open-string termination, escape sequences, and datetime sub-formats) are described in their respective chapters and will be folded in as the grammar is finalized.

See Also

Last updated

Was this helpful?