Extended Backus–Naur form
From Wikipedia, the free encyclopedia
The extended Backus–Naur form (EBNF) is an extension of the basic Backus–Naur form (BNF) metasyntax notation. Originally developed by Niklaus Wirth, the most commonly used variants of EBNF are currently defined by standards, most notably ISO-14977.
1. The following conventions are used:
- Each meta-identifier of Extended BNF is written as one or more words joined together by hyphens;
- A meta-identifier ending with “-symbol” is the name of a terminal symbol of Extended BNF.
2. The normal character representing each operator of Extended BNF and its implied precedence is (highest precedence at the top):
* repetition-symbol - except-symbol , concatenate-symbol | definition-separator-symbol = defining-symbol ; terminator-symbol
3. The normal precedence is over-ridden by the following bracket pairs:
´ first-quote-symbol first-quote-symbol ´ " second-quote-symbol second-quote-symbol " (* start-comment-symbol end-comment-symbol *) ( start-group-symbol end-group-symbol ) [ start-option-symbol end-option-symbol ] { start-repeat-symbol end-repeat-symbol } ? special-sequence-symbol special-sequence-symbol ?
As examples, the following syntax-rules illustrate the facilities for expressing repetition:
aa = "A"; bb = 3 * aa, "B"; cc = 3 * [aa], "C"; dd = {aa}, "D"; ee = aa, {aa}, "E"; ff = 3 * aa, 3 * [aa], "F"; gg = {3 * aa}, "D";
Terminal-strings defined by these rules are as follows:
aa: A bb: AAAB cc: C AC AAC AAAC dd: D AD AAD AAAD AAAAD etc. ee: AE AAE AAAE AAAAE AAAAAE etc. ff: AAAF AAAAF AAAAAF AAAAAAF gg: D AAAD AAAAAAD etc.
When Niklaus Wirth was developing Pascal, he simplified Backus–Naur Form to create EBNF.
All these constructs can be expressed in plain BNF using extra productions and have been added for readability and succinctness.
There is an International standard (ISO 14977) that defines an EBNF. This is now freely available electronically as a zipped pdf file from ISO.
Contents |
[edit] Related work
- The W3C used a different EBNF to specify the XML syntax.
- The British Standards Institute published a standard for an EBNF: BS 6154 in 1981.
- The IETF uses Augmented BNF (ABNF), specified in RFC 2234.
[edit] See also
[edit] References
- Niklaus Wirth: What can we do about the unnecessary diversity of notation for syntactic definitions? CACM, Vol. 20, Issue 11, November 1977, pp. 822-823.
- Roger S. Scowen: Extended BNF — A generic base standard. Software Engineering Standards Symposium 1993.
- Publicly available (zipped) document: link ISO IEC 14977 E
[edit] External links
- Article "EBNF: A Notation to Describe Syntax (PDF)" by Richard E. Pattis describing the functions and syntax of EBNF
- Article "BNF and EBNF: What are they and how do they work?" by Lars Marius Garshol
- Article "The Naming of Parts" by John E. Simpson
- ISO/IEC 14977 : 1996(E)
- Citations from CiteSeer
- RFC 2234 - Augmented BNF for Syntax Specifications: ABNF
- BNF/EBNF variants - a table by Pete Jinks comparing several syntaxes.
This article was originally based on material from the Free On-line Dictionary of Computing, which is licensed under the GFDL.