Up: Table of Contents Working Draft 6-Jan-98

Content Markup Validation Grammar


Informal EBNF grammar for Content Markup structure validation
=============================================================

// Notes
//
// This defines the valid expression trees in content markup
//
// ** it does not define attribute validation -
// ** this has to be done on top
//
// Presentation_tags is a placeholder for a valid
// presentation element start tag or end tag
//
// #PCDATA is the XML parsed character data
//
// symbols beginning with '_' eg. _mmlarg are internal symbols
// (recursive grammar usually required for recognition)
//
// all-lowercase symbols eg. 'ci' are terminal symbols
// representing MathML content elements
//
// symbols beginning with Uppercase are terminals
// representating other tokens
//
// revised sb 3.nov.97, 16.nov.97 and 22.dec.1997


//whitespace  definitions  including presentation_tags

Presentation_tags ::= "presentation"                    //placeholder


Space           ::= #x09 | #xoA | #xoD | #x20                   //tab, lf,
cr, space characters
S                       ::= (Space | Presentation_tags)*
//treat presentation as space

//only for content validation
// characters

Char            ::= Space | [#x21 - #xFFFD]
                                | [#x00010000 - #x7FFFFFFFF]
//valid XML chars

// start & end tag functions
// start(%x) returns a valid start tag for the element %x
// end(%x) returns a valid end tag for the element %x
// empty(%x) returns a valid empty tag for the element %x
//
// start(ci)    ::= ""
// end(cn)              ::= ""
// empty(plus)  ::= ""
//
// The reason for doing this is to avoid writing a grammar
// for all the attributes. The model below is not complete
// for all possible attribute values.

_start(%x)              ::= "<%x" (Char - '>')* ">"     //returns a valid
start tag for the element %x
_end(%x)                ::= "<%x" Space* ">"                    //returns a
valid end tag for the element %x
_empty(%x)              ::= "<%x" (Char - '>')* "/>"    //returns a valid
empty tag for the element %x

_sg(%x)         ::= S _start(%x)
//start tag preceded by optional whitespace
_eg(%x)     ::= _end(%x) S
//end tag followed by optional whitespace
_ey(%x)         ::= S _empty(%x) S
//empty tag preceded & followed by optional whitespace

// mathml content constructs
// allow declare within generic argument type so we can insert it anywhere

_mmlall         ::= _container | _relation | _operator | _qualifier | _other
_mmlarg         ::= declare* _container declare*

_container      ::= _token | _special | _constructor
_token          ::= ci | cn
_special        ::= apply | lambda | relation
_constructor::= interval | list | matrix | matrixrow | set | vector

_other          ::= condition |  declare | sep

_qualifier      ::= lowlimit | uplimit | bvar | degree | logbase

// relations

_relation       ::= _genrel | _setrel | _seqrel2ary
_genrel         ::= _genrel2ary | _genrelnary
_genrel2ary     ::= ne
_genrelnary     ::= eq | leq | lt | geq | gt

_setrel         ::=  _seqrel2ary | _setrelnary
_setrel2ary     ::=  in | notin | notsubset | notprsubset
_setrelnary     ::= subset | prsubset

_seqrel2ary             ::= tendsto

//operators

_operator       ::= _funcop | _sepop | _arithop | _calcop
                | _seqop | _trigop | _statop | _lalgop
                | _logicop | _setop

_funcop ::= _funcop1ary | _funcopnary
_funcop1ary     ::= inverse
_funcopnary     ::= fn                                   // general
user-defined function is nary


// arithmetic operators
// (note minus is both 1ary & 2ary)

_arithop                ::= _arithop1ary | _arithop2ary | _arithopnary  | root
_arithop1ary    ::= exp | factorial | minus
_arithop2ary    ::= quotient | divide | minus | power | rem
_arithopnary    ::= plus | times | max | min | gcd

//calculus

_calcop                 ::= _calcop1ary | log | int | diff | partialdiff
_calcop1ary             ::= ln | totaldiff

// sequences & series

_seqop          ::= sum | product | limit

// trigonometry

_trigop         ::= sin | cos | tan | sec | cosec | cotan | sinh
                | cosh | tanh | sech | cosech | cotanh
                | arcsin | arccos | arctan

// statistics operators

_statop         ::= _statopnary | moment
_statopnary     ::= mean | sdev | var | median | mode

//linear algebra operators

_lalgop                 ::= _lalgop1ary | _lalgopnary
_lalgop1ary             ::= determinant | transpose
_lalgopnary             ::=  select

// logical operators

_logicop                ::= _logicop1ary | _logicopnary | _logicop2ary
_logicop1ary    ::= not
_logicop2ary    ::= implies
_logicopnary    ::= and | or | xor

//set theoretic operators

_setop                  ::= _setop2ary | _setopnary
_setop2ary              ::= setdiff
_setopnary              ::= union | intersect

// operator groups

_unaryop        ::=  _func1ary |        _arithop1ary | _trigop |
_lalgop1ary | _calcop1ary
                            | _logicop1ary

_binaryop       ::=  _arithop2ary | _setop2ary | _logicop2ary
_naryop         ::=  _arithopnary | _statopnary  | _logicopnary
                                | _lalgopnary | _setopnary | _funcopnary

_ispop          ::= int | sum | product
_diffop         ::= diff | partialdiff

_binaryrel      ::= _genrel2ary | _setrel2ary |  _seqrel2ary
_naryrel        ::= _genrelnary | _setrelnary

//separator

sep                     ::=  _ey(sep)

// leaf tokens  and data content of leaf elements
// note _mdata includes Presentation constructs here.

_mdata          ::= (#PCDATA | sep | Presentation_tags)*

ci                      ::=  _sg(ci) _mdata _eg(ci)
cn                      ::=  _sg(cn) _mdata _eg(cn)

//condition -  "such that" container

condition       ::= _sg(condition) ci+ e+ _eg(condition)

// domains for integral, sum , product

_ispdomain  ::= (lowlimit  uplimit?)
                | uplimit
                | interval
                | condition

//equations and relations - e(quation) uses lisp-like syntax (like apply)

relation        ::= ( _sg(relation) _ebody _eg(relation) )
_ebody          ::= ( _binaryrel _mmlarg _mmlarg )
                    | ( _naryrel _mmlarg*  )

// apply construct

apply           ::= _sg(apply) _applybody _eg(apply)

_applybody      ::= ( _unaryop _mmlarg  )
//the heart of the matter
                                | (_binaryop _mmlarg _mmlarg)
                                | (_naryop _mmlarg*)
                                | (_naryop condition)
                                | (_ispop _mmlarg _ispdomain? bvar?)
                                | (_diffop _mmlarg bvar*)
                                | (limit _mmlarg (condition bvar?)?     )
                                | (log _mmlarg logbase?)
                                | (moment _mmlarg* degree?)
//
                                | (root _mmlarg degree?)
//default is square-root

// fn construct

fn                      ::= _sg(fn) _fnbody _eg(fn)
_fnbody         ::=  _mdata | container

//lambda construct

lambda          ::=  _sg(lambda) _lambdabody _eg(lambda)
_lambdabody     ::=  ci+ (apply | fn | ci | cn)
//multivariate lambda calculus

//declare construct

declare         ::= _sg(declare) _declarebody _eg(declare)
_declarebody    ::= ci (fn | constructor)?

// constructors

interval        ::=  _sg(interval) _mmlarg _mmlarg _eg(interval)
//start, end define integral

set                     ::=  _sg(set) _lsbody _eg(set)
_lsbody         ::=  (_mmlarg*)
                                 | (condition)

list            ::= _sg(list) _lsbody _eg(list)

matrix          ::= _sg(matrix) matrixrow* _eg(matrix)

matrixrow       ::= _sg(matrixrow) _mmlall* _eg(matrixrow)
//allows matrix of operators

vector          ::= _sg(vector) _mmlarg* _eg(vector)

//qualifiers

lowlimit        ::= _sg(lowlimit) (_mmlarg | e) _eg(lowlimit)
uplimit         ::= _sg(uplimit) (_mmlarg | e) _eg(uplimit)
bvar            ::= _sg(bvar) ci degree? _eg(bvar)
degree          ::= _sg(degree) _mmlarg _eg(degree)
logbase         ::= _sg(logbase) _mmlarg _eg(logbase)

//relations and operators
// (one declaration for each operator and relation element)

_relation       ::= _ey(%relation)
//eg.   
_operator       ::= _ey(%operator)
//eg.  

//the top level math element

math            ::= _sg(math) mmlall* _eg(math)



Up: Table of Contents