Content Markup Validation Grammar (original ) (raw )This presents an informal EBNF grammar that can be used to validate the structure of Content Markup.
It defines the valid expression trees in content markup. It does not define the rules for attribute validation. That must be done separately.
The non-terminal Presentation_tags is a placeholder for a valid presentation element start tag or end tag.
The string #PCDATA
denotes XML parsed character data.
Symbols beginning with '_' (for example _mmlarg ) are internal symbols. A recursive grammar is usually required for their recognition.
Symbols which are all in lowercase symbols (for example 'ci') are terminal symbols representing MathML content elements.
Symbols beginning with Uppercase letters are terminals representating other tokens.
[1]
Presentation_tags
::=
"presentation"
/* placeholder */
[2]
Space
::=
#x09 | #x0A
#x0D
#x20
/* tab, lf, cr, space characters */
[3]
S
::=
(Space | Presentation_tags" )*
/* treat presentation as space */
Characters, only for content validation characters
[4]
Char
::=
#x9 | #xA
#xD
[#x20-#xD7FF]
[#xE000-#xFFFD]
[#x10000-#x10FFFF]
/* valid XML chars */
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 and end tag functions
[5]
_start(\%x)
::=
"<\%x" (Char - '>')* ">"
/* returns a valid start tag for the element \%x */
[6]
_end(\%x)
::=
"<\%x" Space * ">"
/* returns a valid end tag for the element \%x */
[7]
_empty(\%x)
::=
"<\%x" (Char - '>')* "/>"
/* returns a valid empty tag for the element \%x */
[8]
_sg(\%x)
::=
S _start (\%x)
/* start tag preceded by optional whitespace */
[9]
_eg(\%x)
::=
_end (\%x) S
/* end tag followed by optional whitespace */
[10]
_ey(\%x)
::=
S _empty (\%x) S
/* empty tag preceded and followed by optional whitespace */
semantics, annotation, etc.
[11]
semantics
::=
_sg (semantics)_mmlarg _annot *_eg (semantics)
[12]
annotation
::=
_sg (annotation) #PCDATA_eg (annotation)
[13]
annotation-xml
::=
_sg (annotation-xml)_ANY _eg (annotation-xml)
[14]
_ANY
::=
"AnyXML"
/* placeholder for wellformed XML Fragment (not Mixed Content) */
[15]
_annot
::=
annotation | annotation-xml
mathml content constructs
[16]
_mmlarg
::=
_container | _token
_operator
_relation
[17]
_container
::=
_special | _constructor
[18]
_token
::=
ci | cn
csymbol
_constantsym
[19]
_special
::=
apply | lambda
reln
fn
semantics
[20]
_constructor
::=
interval | list
matrix
matrixrow
set
vector
piecewise
piece
otherwise
[21]
_qualifier
::=
lowlimit | uplimit
degree
logbase
domainofapplication
momentabout
condition
/* interval is both a qualifier and a constructor */
[22]
_constantsym
::=
integers | rationals
reals
naturalnumbers
complexes
primes
exponentiale
imaginaryi
notanumber
true
false
pi
eulergamma
infinity
relations
operators
functional operators
[32]
_funcop
::=
_funcop1ary | _funcopnary
[33]
_funcop1ary
::=
inverse | ident
domain
codomain
image
[34]
_funcopnary
::=
fn| compose
/* general user-defined function is n-ary */
(note minus
is both 1ary and 2ary)
arithmetic operators
[35]
_arithop
::=
_arithop1ary | _arithop2ary
_arithopnary
root
[36]
_arithop1ary
::=
abs | conjugate
factorial
minus
arg
real
imaginary
floor
ceiling
[37]
_arithop2ary
::=
quotient | divide
minus
power
rem
[38]
_arithopnary
::=
plus | times
max
min
gcd
lcm
calculus and vector calculus
[39]
_calcop
::=
int | diff
partialdiff
[40]
_vcalcop
::=
divergence | grad
curl
laplacian
sequences and series
[41]
_seqop
::=
sum | product
limit
elementary classical functions and trigonometry
[42]
_classop
::=
exp | ln
log
[43]
_trigop
::=
sin | cos
tan
sec
csc
cot
sinh
cosh
tanh
sech
csch
coth
arcsin
arccos
arctan
statistics operators
[44]
_statop
::=
_statopnary | moment
[45]
_statopnary
::=
mean | sdev
variance
median
mode
linear algebra operators
[46]
_lalgop
::=
_lalgop1ary |_lalgop2ary
_lalgopnary
[47]
_lalgop1ary
::=
determinant | transpose
[48]
_lalgop2ary
::=
vectorproduct | scalarproduct
outerproduct
[49]
_lalgopnary
::=
selector
logical operators
set theoretic operators
[55]
_setop
::=
_setop1ary |_setop2ary
_setopnary
[56]
_setop1ary
::=
card
[57]
_setop2ary
::=
setdiff
[58]
_setopnary
::=
union | intersect
cartesianproduct
operator groups
separator
leaf tokens and data content of leaf elements
condition
- constraints. constraints contains either a single reln
(relation), or an apply holding a logical combination of relations, or a set (over which the operator should be applied).
condition
[73]
condition
::=
_sg (condition) reln | apply
set _eg (condition)
domains for integral, sum , product, and specials
[74]
_domainofapp
::=
domainofapplication | _domainabbrev
[75]
_domainabbrev
::=
(lowlimit uplimit?) | uplimit
interval
condition
Note that apply
is used in place of the deprecated reln
in MathML2.0 for relational operators as well as arithmetic, algebraic etc.
apply construct
Equations and relations - reln
uses lisp-like syntax (like apply
) the bvar
and condition
elements are used to construct a "such that" or "where" constraint on the relation. Note that reln
is deprecated but still valid in MathML2.0.
equations and relations
fn construct Note that fn is deprecated but still valid in MathML2.0
lambda
construct
declare
construct
[84]
declare
::=
_sg (declare) _declarebody _eg (declare)
[85]
_declarebody
::=
ci (fn | constructor)?
constructors
bound variables
other qualifiers - note the contained _mmlarg could be a reln
The top level math
element. Allow declare
only at the head of a math
element.
math