From: David McCusker <davidmc@netscape.com>
Subject: [MORK] version 1.1 grammar 18Dec98
Date: 1998/12/18
Message-ID: <367AD1D1.A06EA4A3@netscape.com>#1/1
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
Organization: Netscape
Mime-Version: 1.0
Reply-To: davidmc@netscape.com
Newsgroups: netscape.public.mozilla.mail-news


/* see separate post for summary of 1.0 -> 1.1 syntax changes for */

/* mdb="abstract mail/news db interfaces, also known by nsIMsgDb" */
/* mork="summary file format defining mdb reference implementation" */
/* z="zany mongrel Mork terse syntax roughly inspired by Lisp" */
/* x="XML style Mork verbose syntax embeddable in XML documents" */
/* l="Lisp style Mork paren syntax for hypothetical comparisons" */
/* Start="starting production for a Mork document" */

/* <production-suffixes XmlMork="xm" LispMork="lm" ZanyMork="zm"/> */

zm:Start   ::= zm:Magic zm:LineEnd zm:Header (zm:Content | zm:Group)*
zm:Magic   ::= '// <!-- <mdb:mork:z v="1.1"/> -->'
zm:Header  ::= '@[' zm:S? zm:Id zm:RowItem* zm:S? ']@' /* file row */
zm:Content ::= (zm:Dict | zm:Table | zm:Update)*

zm:S ::= (#x20 | #x9 | #xA | #xD | zm:Continue | zm:Comment)+ /* space */

zm:LineEnd  ::= #xA #xD | #xD #xA | #xA | #xD /* 1 each if possible */
zm:NonCRLF ::= [#x0 - #xFF] - (#xD | #xA)
zm:Comment  ::= '//' zm:NonCRLF* zm:LineEnd /* C++ style comment */
zm:Continue ::= '\' zm:LineEnd

zm:Hex   ::= [0-9a-fA-F] /* a single hex digit */
zm:Id    ::= zm:Hex+     /* a row, table, or value id is naked hex */

zm:AnyRef    ::= zm:TableRef | zm:RowRef | zm:ValueRef
zm:TableRef  ::= zm:S? 't' zm:Id
zm:RowRef    ::= zm:S? 'r' zm:Id
zm:ValueRef  ::= zm:S? '^' zm:Id /* use '^' to avoid zm:Name ambiguity */

zm:MoreName  ::= [a-zA-Z:_+-?!]
zm:Name      ::= [a-zA-Z:_] zm:MoreName*
/* names only need to avoid space and '^', so this is more limiting */

zm:Update  ::= zm:S? [!+-] (zm:Row | zm:Table)
/* +="<mdb:add/>" (insert) -="<mdb:cut/>" (remove) !="<mdb:put/>" (set) */

/* groups must be ignored until properly terminated */
zm:Group       ::= zm:GroupStart zm:Content zm:GroupEnd /* transaction */
zm:GroupStart  ::= zm:S? '@$${' zm:Id '{@' /* transaction id has own space */
zm:GroupEnd    ::= zm:GroupCommit | zm:GroupAbort
zm:GroupCommit ::= zm:S? '@$$}' zm:Id '}@'  /* id matches start id */
zm:GroupAbort  ::= zm:S? '@$$}~abort~' zm:Id '}@' /* id matches start id */
/* We must allow started transactions to be aborted in summary files. */
/* Note '$$' will never occur unescaped in values we will see in Mork. */

zm:Dict      ::= zm:S? '<' zm:DictItem* zm:S? '>'
zm:DictItem  ::= zm:MetaDict | zm:Alias
zm:MetaDict  ::= zm:S? '<' zm:S? zm:Cell* zm:S? '>' /* meta attributes */
zm:Alias     ::= zm:S? '(' zm:Id zm:S? zm:Value ')'

zm:Table     ::= zm:S? '{' zm:S? zm:Id zm:TableItem* zm:S? '}'
zm:TableItem ::= zm:MetaTable | zm:RowRef | zm:Row
zm:MetaTable ::= zm:S? '{' zm:S? zm:Cell* zm:S? '}' /* meta attributes */

zm:Row       ::= zm:S? '[' zm:S? zm:Id zm:RowItem* zm:S? ']'
zm:RowItem   ::= zm:MetaRow | zm:Cell
zm:MetaRow   ::= zm:S? '[' zm:S? zm:Cell* zm:S? ']' /* meta attributes */

zm:Cell      ::= zm:S? '(' zm:Column zm:S? zm:Slot? ')'
zm:Column    ::= zm:S? (zm:Name | zm:ValueRef)
zm:Slot      ::= zm:Value | zm:AnyRef zm:S?

zm:Value   ::= '=' ([^)] | '\' zm:NonCRLF | zm:Continue | zm:Dollar)*
/* content ')', '\', and '$' must be quoted with '\' inside zm:Value */
zm:Dollar  ::= '$' zm:Hex zm:Hex /* hex encoding of one byte */
/* using '$' instead of '%' helps avoid the need to quote URL markup */