Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Backus–Naur form
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Example== A practical illustration of BNF is a specification for a simplified U.S. [[Address (geography)|postal address]]: <syntaxhighlight lang="bnf"><postal-address> ::= <name-part> <street-address> <zip-part> <name-part> ::= <personal-part> <last-name> <opt-suffix-part> <EOL> | <personal-part> <name-part> <personal-part> ::= <first-name> | <initial> "." <street-address> ::= <house-num> <street-name> <opt-apt-num> <EOL> <zip-part> ::= <town-name> "," <state-code> <ZIP-code> <EOL> <opt-suffix-part> ::= "Sr." | "Jr." | <roman-numeral> | "" <opt-apt-num> ::= "Apt" <apt-num> | ""</syntaxhighlight> This translates into English as: * A postal address consists of a name-part, followed by a [[street name|street-address]] part, followed by a [[ZIP Code|zip-code]] part. * A name-part consists of either: a personal-part followed by a [[last name]] followed by an optional [[Suffix (name)|suffix]] (Jr. Sr., or dynastic number) and [[end-of-line]], or a personal part followed by a name part (this rule illustrates the use of [[Recursion (computer science)|recursion]] in BNFs, covering the case of people who use multiple first and middle names and initials).<ref>{{FOLDOC|Backus-Naur+Form}}</ref> * A personal-part consists of either a [[first name]] or an [[initial]] followed by a dot. * A street address consists of a house number, followed by a street name, followed by an optional [[apartment]] specifier, followed by an end-of-line. * A zip-part consists of a [[town]]-name, followed by a comma, followed by a [[U.S. postal abbreviations|state code]], followed by a ZIP-code followed by an end-of-line. * An opt-suffix-part consists of a suffix, such as "Sr.", "Jr." or a [[Roman numerals|roman-numeral]], or an empty string (i.e. nothing). * An opt-apt-num consists of a prefix "Apt" followed by an apartment number, or an empty string (i.e. nothing). Note that many things (such as the format of a first-name, apartment number, ZIP-code, and Roman numeral) are left unspecified here. If necessary, they may be described using additional BNF rules.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)