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      = name [ ":" 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

Values

Schema (MemberDef and SchemaDef)

Lexical

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?