This is, to the best of my ability, the BNF for JON. If you see any improvements that can be made, please don't hesitate to suggest the correction through the sourceforge project forums.
As far as syntax goes, I'll try to obey the same conventions as the Backus Naur form wikipedia article except that non-terminals will be rendered without any delimiters. White space is allowed between any consecutive tokens and will be omitted from the definitions.
The terminal identifier is a sequence of at least one alphanumeric, dollar sign, dash, underscore, or period. There is an additional rule that makes array classes easier to express, namely an identifier may have any number of "[]" symbols suffixed to itself.
identifer ::= /[-_.$a-zA-Z0-9]+(\[\])*/
A reference is a terminal used as a special identifier for a object to maintain and express object relationships. It may either exist as the left hand side of a reference assignment, or it may simply exist alone as a reference to another assignment defined elsewhere. A reference is a sequence of at least one alphanumeric, dollar sign, dash, underscore, or period following a single ampersand.
reference ::= /&[-_.$a-zA-Z0-9]+/
There is also the notion of a string which works much the same way as a Java String literal. It is a sequence of characters enclosed by double quotes. To include double quotes in a string simply escape the character with a backslash.
string ::= /"([^"]|\\")*"/
The root level parse symbol is Element and represents a single reconstructable, identifiable object. * reference is assumed to refer to an assignment defined elsewhere * reference = CastedObj is a reference assignment. Any appearance of the reference refers to the specified CastedObj * CastedObj is a object that cannot be referenced elsewhere.
<Element> ::= reference | reference "=" <CastedObj> | <CastedObj>
A CastedObj is a flattened object optionally preceeded by a class cast
<CastedObj> ::= <ClassCast> <FlattenedObj> | <FlattenedObj>
A ClassCast is a class identifier enclosed by parentheses. The major difference between a JON cast and a Java cast is that the class identifier may be assigned a reference. This gives a kind of parallel to the import keyword in Java.
<ClassCast> ::= "(" <ClassElement> ")"
<ClassElement> ::= reference | reference "=" identifier | identifierA FlattenedObj is the main workhorse of the JON specification. This is the set of all the possible serialization types handled by JON.
<FlattenedObj> ::= <List> | <Object> | string | identifier
A List is a possibly empty ordered set of Element symbols enclosed by square brackets and separated by commas.
<List> ::= "[" <Elements> "]" | "[" "]" <Elements> ::= <Element> | <Element> "," <Elements>
An Object is a possibly empty ordered set of Partition symbols enclosed by curly braces and separated by pipes (vertical bars).
<Object> ::= "{" <Partitions> "}" | "{" "}"
<Partitions> ::= <Partition> | <Partition> "|" <Partitions>A Partition is either a set of Element symbols or a set of Element symbol relations called an Entry either way separated by a comma.
<Partition> ::= <Elements> | <Entries> <Entries> ::= <Entry> | <Entry> "," <Entries>
An Entry is a relation between Element symbols separated by a colon.
<Entry> ::= <Element> ":" <Element>