SyntaxNotation
We use a variant of EBNF (Extended Backus Naur Form) that is similar to regular expressions. We use a (slightly modified) subset of http://www.w3.org/TR/REC-xml/#sec-notation, the notation used by W3C to specify XML
Each rule in the grammar defines one symbol, in the form
- symbol = expression we use the simpler =, like EBNF, whereas W3C uses ::=
An expression - the right hand side of a rule - may be
- symbol a symbol which is defined as the left hand side of another or the same rule"string" matches a literal string matching that given inside the double quotes.'string' matches a literal string matching that given inside the single quotes.
These symbols may be combined to match more complex patterns as follows, where A and B represent expressions:
- (expression) expression is treated as a unit and may be combined as described in this list.A? matches A or nothing; optional A.A B matches A followed by B. This operator has higher precedence than alternation; thus A B | C D is identical to (A B) | (C D).A | B matches A or B.A - B matches any string that matches A but does not match B.A+ matches one or more occurrences of A. Concatenation has higher precedence than alternation; thus A+ | B+ is identical to (A+) | (B+).A* matches zero or more occurrences of A. Concatenation has higher precedence than alternation; thus A* | B* is identical to (A*) | (B*).
Other notations used in the productions are:
- (* ... *) comment. (as in EBNF, W3C uses /* ... */). Furthermore, wie use layout conventions for comments and rules like symbol = (* ... *) to describe a production that is easier defined in free text than by a formal syntax
Vergleich verschiedener Varianten von BNF
- my: wie oben definiert
- W3C in XML Definition: http://www.w3.org/TR/REC-xml/#sec-notation
- EBNF: http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form
- BNF: http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form
EBNF dagegen, hat einen expliziten KonkatinierungsOperator und verschiedenen Klammern für Multiplizitäten:
Usage | my | W3C | EBNF | BNF |
---|---|---|---|---|
symbol | name | name | name | <...> |
definition | = | ::= | = | ::= |
termination | ; | |||
concatenation | , | |||
alternation | | | | | | | | |
option | ? | ? | [ ... ] | none |
repetition 0..n | * | * | { ... } | none |
repetition 1..n | + | + | none | none |
grouping | ( ... ) | ( ... ) | ( ... ) | none |
terminal string | " ... " | " ... " | " ... " | ... |
terminal string | ' ... ' | ' ... ' | ' ... ' | |
exception | - | - | - | none |
comment | (* ... *) | /* ... */ | (* ... *) | none |
special sequence | ? ... ? | |||
constraint | [...: ... ] |