The Backus-Naur form (BNF) (also known as Backus normal form) is a formal metasyntax[?] used to express context-free grammars: that is, a formal way to describe other formal languages.
It is widely used as a notation for the grammars of computer programming languages, command sets and communication protocols. However, it is seldom documented anywhere, so that it must usually be learned by osmosis. Some variants, for example ABNF, are documented, though.
It was originally named after John Backus and later (at the suggestion of Donald Knuth) also after Peter Naur, two pioneers in computer science, namely in the art of compiler design[?], as part of creating the rules for Algol 60.
<postal-address> ::= <name-part> <street-address> <zip-part>
<personal-part> ::= <name> | <initial> "."
<name-part> ::= <personal-part> <last-name> [<jr-part>] <EOL> | <personal-part> <name-part>
<street-address> ::= [<apt>] <house-num> <street-name> <EOL>
<zip-part> ::= <town-name> "," <state-code> <ZIP-code> <EOL>
This translates into English as:
Note that many things (such as the format of a personal-part, apartment specifier, or ZIP-code) are left unspecified. These lexical details are presumed to be obvious from context or specified somewhere nearby.
This article (or an earlier version of it) contains material from FOLDOC, used with permission.
wikipedia.org dumped 2003-03-17 with terodump