Jump to content

Backus–Naur form: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Undid revision 702343079 by Opencooper: 'BCE' is in use (see link), and is less religious than 'BC'
WP:Dash correct example.
 
(240 intermediate revisions by more than 100 users not shown)
Line 1: Line 1:
{{Short description|Formalism to describe programming languages}}
{{Distinguish|BCNF|Boyce–Codd normal form}}
{{Distinguish|Boyce–Codd normal form}}
In [[computer science]], '''BNF''' ('''Backus Normal Form''' or '''Backus–Naur Form''') is one of the two main [[metasyntax|notation techniques]] for [[context-free grammar]]s, often used to describe the [[Syntax (programming languages)|syntax]] of [[Formal language#Programming languages|languages]] used in computing, such as computer [[programming language]]s, [[document format]]s, [[instruction set]]s and [[communication protocol]]s; the other main technique for writing context-free grammars is the [[Van Wijngaarden grammar|van Wijngaarden form]].<ref name = "Grune1999">{{cite book | last = Grune |first = Dick |title = Parsing Techniques: A Practical Guide|publisher = Springer |location = US |year = 1999}}</ref> They are applied wherever exact descriptions of languages are needed: for instance, in official language specifications, in manuals, and in textbooks on programming language theory.
{{Multiple issues|
{{Manual|date=December 2023}}
{{Technical|date=December 2023}}
{{More citations needed|date=December 2023}}
}}


In [[computer science]], '''Backus{{Ndash}}Naur form''' ('''BNF'''; {{IPAc-en|ˌ|b|æ|k|ə|s|_|ˈ|n|aʊər}}; '''Backus normal form''') is a notation used to describe the [[Syntax (programming languages)|syntax]] of [[programming language]]s or other [[formal language]]s. It was developed by [[John Backus]] and [[Peter Naur]]. BNF can be described as a [[metasyntax]] notation for [[context-free grammar]]s. Backus–Naur form is applied wherever exact descriptions of languages are needed, such as in official language specifications, in manuals, and in textbooks on programming language theory. BNF can be used to describe [[document format]]s, [[instruction set]]s, and [[communication protocol]]s.
Many extensions and variants of the original Backus–Naur notation are used; some are exactly defined, including ''[[Extended Backus–Naur Form]]'' (EBNF) and ''[[Augmented Backus–Naur Form]]'' (ABNF).


Over time, many extensions and variants of the original Backus–Naur notation have been created; some are exactly defined, including [[extended Backus–Naur form]] (EBNF) and [[augmented Backus–Naur form]] (ABNF).
==History==


==Overview==
The idea of describing the structure of language using rewriting rules can be traced back to at least the work of [[Pāṇini]] (who lived sometime between the 7th and 4th century [[BCE]]).<ref>{{cite web|url=http://www-gap.dcs.st-and.ac.uk/~history/Biographies/Panini.html |title=Panini biography |publisher=School of Mathematics and Statistics, University of St Andrews, Scotland|accessdate=2014-03-22}}</ref><ref>{{cite journal |last=Ingerman |first=Peter Zilahy |date=March 1967 |title="Pāṇini-Backus Form" Suggested |url=http://dl.acm.org/citation.cfm?id=363165 |journal=Communications of the ACM |publisher=Association for Computing Machinery |volume=10 |issue=3 |page=137 |doi=10.1145/363162.363165 |accessdate=24 September 2014}} Ingerman suggests that the Backus Normal Form be renamed to the [[Pāṇini]]-Backus Form, to give due credit to Pāṇini as the earliest independent inventor.</ref>
BNFs describe how to combine different symbols to produce a syntactically correct sequence. BNFs consist of three components: a set of non-terminal symbols, a set of terminal symbols, and rules for replacing non-terminal symbols with a sequence of symbols.<ref name="janikow">{{cite web |first1=Cezary Z. |last1=Janikow |url=http://www.cs.umsl.edu/~janikow/cs4280/bnf.pdf |title=What is BNF?}}</ref> These so-called "derivation rules" are written as
His notation to describe [[Sanskrit]] word structure notation is equivalent in power to that of Backus and has many similar properties.
<syntaxhighlight lang="bnf">
<symbol> ::= __expression__
</syntaxhighlight>

where:

* <code><[[symbol]]></code><ref name="class" /> is a ''[[nonterminal]]'' variable that is always enclosed between the pair <>.
* {{Code|1=::=}} means that the symbol on the left must be replaced with the expression on the right.
* [[expression (mathematics)|<code>__expression__</code>]] consists of one or more sequences of either terminal or nonterminal symbols where each sequence is separated by a [[vertical bar]] "|" indicating a [[alternation (formal language theory)|choice]], the whole being a possible substitution for the symbol on the left.

All syntactically correct sequences must be generated in the following manner:

* Initialize the sequence so that it just contains one start symbol.
* Apply derivation rules to this start symbol and the ensuing sequences of symbols.<ref name="janikow" />

Applying rules in this manner can produce longer and longer sequences, so many BNF definitions allow for a special "delete" symbol to be included in the specification. We can specify a rule that allows us to replace some symbols with this "delete" symbol, which is meant to indicate that we can remove the symbols from our sequence and still have a syntactically correct sequence.<ref name="janikow" />

==Example==
As an example, consider this possible BNF for a 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.

==History==
The idea of describing the structure of language using [[Rewrite rule|rewriting rules]] can be traced back to at least the work of [[Pāṇini]], an ancient Indian Sanskrit grammarian and a revered scholar in Hinduism who lived sometime between the 6th and 4th century [[Before Christ|BC]].<ref>{{cite web|url=http://www-gap.dcs.st-and.ac.uk/~history/Biographies/Panini.html |title=Panini biography |publisher=School of Mathematics and Statistics, University of St Andrews, Scotland|access-date=2014-03-22}}</ref><ref>{{cite journal |last=Ingerman |first=Peter Zilahy |date=March 1967 |title="Pāṇini-Backus Form" Suggested |journal=Communications of the ACM |publisher=Association for Computing Machinery |volume=10 |issue=3 |page=137 |doi=10.1145/363162.363165 |s2cid=52817672 |doi-access=free }} Ingerman suggests that the Backus Normal Form be renamed to the [[Pāṇini]]-Backus Form, to give due credit to Pāṇini as the earliest independent inventor.</ref> His notation to describe [[Sanskrit]] word structure is equivalent in power to that of Backus and has many similar properties.


In Western society, grammar was long regarded as a subject for teaching, rather than scientific study; descriptions were informal and targeted at practical usage. In the first half of the 20th century, [[linguistics|linguists]] such as [[Leonard Bloomfield]] and [[Zellig Harris]] started attempts to formalize the description of language, including phrase structure.
In Western society, grammar was long regarded as a subject for teaching, rather than scientific study; descriptions were informal and targeted at practical usage. In the first half of the 20th century, [[linguistics|linguists]] such as [[Leonard Bloomfield]] and [[Zellig Harris]] started attempts to formalize the description of language, including [[phrase structure rules|phrase structure]].


Meanwhile, string rewriting rules as [[mathematical formalism|formal, abstract system]]s were introduced and studied by mathematicians such as [[Axel Thue]] (in 1914), [[Emil Post]] (1920s–40s) and [[Alan Turing]] (1936). [[Noam Chomsky]], teaching linguistics to students of [[information theory]] at [[MIT]], combined linguistics and mathematics, by taking what is essentially Thue's formalism as the basis for the description of the syntax of [[natural language]]. He also introduced a clear distinction between generative rules (those of [[context-free grammar]]s) and transformation rules (1956).<ref>{{cite journal | last = Chomsky
Meanwhile, [[Semi-Thue system|string rewriting rules]] as [[formal logical systems]] were introduced and studied by mathematicians such as [[Axel Thue]] (in 1914), [[Emil Post]] (1920s–40s) and [[Alan Turing]] (1936). [[Noam Chomsky]], teaching linguistics to students of [[information theory]] at [[MIT]], combined linguistics and mathematics by taking what is essentially Thue's formalism as the basis for the description of the syntax of [[natural language]]. He also introduced a clear distinction between generative rules (those of [[context-free grammar]]s) and transformation rules (1956).<ref>{{cite journal
|last=Chomsky
| first = Noam | year = 1956 | title = Three models for the description of language | url = http://www.chomsky.info/articles/195609--.pdf | journal = IRE Transactions on Information Theory | volume = 2 | issue = 2 | pages = 113–24 | doi= 10.1109/TIT.1956.1056813 | format = PDF}}</ref><ref name="Chomsky1957">{{cite book |last = Chomsky |first = Noam |title = [[Syntactic Structures]] |publisher = Mouton | location = The Hague |year = 1957}}</ref>
|first=Noam
|year=1956
|title=Three models for the description of language
|url=http://www.chomsky.info/articles/195609--.pdf
|journal=IRE Transactions on Information Theory
|volume=2
|issue=3
|pages=113–24
|doi=10.1109/TIT.1956.1056813
|s2cid=19519474
|url-status=dead
|archive-url=https://web.archive.org/web/20100919021754/http://chomsky.info/articles/195609--.pdf
|archive-date=2010-09-19
}}</ref><ref name="Chomsky1957">{{cite book |last = Chomsky |first = Noam |title = Syntactic Structures |publisher = Mouton | location = The Hague |year = 1957|title-link = Syntactic Structures }}</ref>


[[John W. Backus|John Backus]], a programming language designer at [[IBM]], proposed a metalanguage of "metalinguistic formulas"<ref name=class>The meaning of syntactic formula may be further explained by saying that words enclosed in the brackets < >, like <ab>, denote classes whose members are sequences of basic symbols. Class designations of this kind are found in any description of a language. For describing ordinary natural languages designation like word, verb, noun, are used. , Peter Naur (1961).{{cite web|url=http://dl.acm.org/citation.cfm?id=1064049&CFID=648579078&CFTOKEN=25521706|title=A COURSE ON ALGOL PROGRAMMING|page=5, Note 1. |accessdate=26 March 2015}}
[[John Backus]], a programming language designer at [[IBM]], proposed a [[metalanguage]] of "metalinguistic formulas"{{refn|name="class"|The meaning of syntactic formula may be further explained by saying that words enclosed in the brackets <code>&lt; &gt;</code>, like <code>&lt;ab&gt;</code>, denote classes whose members are sequences of basic symbols. Class designations of this kind are found in any description of a language. For describing ordinary natural languages designation like word, verb, noun, are used. .<ref>{{cite web|first=Peter|last=Naur|date=1961|publisher=Regnecentralen|publication-place=Copenhagen |url=http://archive.computerhistory.org/resources/text/algol/ACM_Algol_bulletin/1064048/frontmatter.pdf|title=A COURSE OF ALGO L 60 PROGRAMMING with special reference to the DASK ALGOL system|access-date=26 March 2015}}</ref>{{rp|5|at=Note 1}}
</ref><ref name="Backus.1969">
}}<ref name="Backus.1969">
{{Cite book
{{Cite book
| last = Backus
| last = Backus
| first = J.W.
| first = J. W.
| author-link = John W. Backus
| author-link = John W. Backus
| year = 1959
| year = 1959
Line 33: Line 98:
| date = August 1995
| date = August 1995
| url = http://www.cs.man.ac.uk/~pjj/farrell/comp2.html#EBNF
| url = http://www.cs.man.ac.uk/~pjj/farrell/comp2.html#EBNF
| accessdate = May 11, 2011
| access-date = May 11, 2011
| archiveurl= http://web.archive.org/web/20110605061825/http://www.cs.man.ac.uk/~pjj/farrell/comp2.html#EBNF| archivedate= 5 June 2011 <!--DASHBot-->| deadurl= no}}
| archive-url= https://web.archive.org/web/20110605061825/http://www.cs.man.ac.uk/~pjj/farrell/comp2.html#EBNF| archive-date= 5 June 2011 | url-status= live}}
</ref>
</ref>
to describe the syntax of the new programming language IAL, known today as [[ALGOL 58]] (1959), and first used in the ALGOL 60 report.
to describe the syntax of the new programming language IAL, known today as [[ALGOL 58]] (1959). His notation was first used in the ALGOL 60 report.


BNF is a notation for Chomsky's context-free grammars.
BNF is a notation for Chomsky's context-free grammars. Backus was familiar with Chomsky's work.<ref>
Apparently, Backus was familiar with Chomsky's work.<ref>
{{cite web
{{cite web
| last = Fulton, III
| last = Fulton, III
Line 47: Line 111:
| url = http://betanews.com/2007/03/20/john-w-backus-1924-2007
| url = http://betanews.com/2007/03/20/john-w-backus-1924-2007
|publisher = BetaNews. Inc.
|publisher = BetaNews. Inc.
| accessdate = Jun 3, 2014
| access-date = Jun 3, 2014
}}
}}
</ref>
</ref>


As proposed by Backus, the formula defined "classes" whose names are enclosed in angle brackets. For example, <ab>. Each of these names denotes a class of basic symbols.<ref name=class/>
As proposed by Backus, the formula defined "classes" whose names are enclosed in angle brackets. For example, <code>&lt;ab&gt;</code>. Each of these names denotes a class of basic symbols.<ref name=class/>


Further development of ALGOL led to [[ALGOL 60]]. In the committee's 1963 report, [[Peter Naur]] called Backus's notation '''Backus Normal Form'''. [[Donald Knuth]] argued that BNF should rather be read as '''Backus–[[Peter Naur|Naur]] Form''', as it is
Further development of [[ALGOL]] led to [[ALGOL 60]]. In the committee's 1963 report, [[Peter Naur]] called Backus's notation ''Backus normal form''. [[Donald Knuth]] argued that BNF should rather be read as ''Backus–Naur form'', as it is "not a [[normal form (term rewriting)|normal form]] in the conventional sense",<ref>
"not a [[Normal form (term rewriting)|normal form]] in the conventional sense",<ref>
{{cite journal
{{cite journal
|last= Knuth
|last= Knuth
|first= Donald E.
|first= Donald E.
|authorlink= Donald Knuth
|author-link= Donald Knuth
|title= Backus Normal Form vs. Backus Naur Form
|title= Backus Normal Form vs. Backus Naur Form
|journal= Communications of the ACM
|journal= Communications of the ACM
Line 66: Line 129:
|year= 1964
|year= 1964
|doi= 10.1145/355588.365140
|doi= 10.1145/355588.365140
|s2cid= 47537431
|doi-access= free
}}</ref>
}}</ref>
unlike, for instance, [[Chomsky Normal Form]]. The name '''Pāṇini Backus form''' has also been suggested in view of the fact that the expansion '''Backus Normal Form''' may not be accurate, and that [[Pāṇini]] had independently developed a similar notation earlier.
unlike, for instance, [[Chomsky normal form]]. The name ''Pāṇini Backus form'' was also once suggested in view of the fact that the expansion ''Backus normal form'' may not be accurate, and that [[Pāṇini]] had independently developed a similar notation earlier.<ref>
<ref>
{{cite journal
{{cite journal
|last= Ingerman
|last= Ingerman
Line 79: Line 143:
|year= 1967
|year= 1967
|doi= 10.1145/363162.363165
|doi= 10.1145/363162.363165
|s2cid= 52817672
|doi-access= free
}}</ref>
}}</ref>


BNF is described by Peter Naur in the ALGOL 60 report as ''metalinguistic formula'':<ref name=ALGOL60RPT>Revised ALGOL 60 report section. 1.1.{{cite web|url=http://www.masswerk.at/algol60/report.htm|title=ALGOL 60|access-date=April 18, 2015}}</ref>
BNF, as described by Peter Naur in the ALGOL 60 report are '''''metalinguistic formula'''''. "''Sequences of characters enclosed in the brackets <> represent metalinguistic variables whose values are sequences of symbols. The marks "::=" and "|" (the latter with the meaning of "or") are metalingustic connectives. Any mark in a formula, which is not a variable or a connective, denotes itself. Juxtaposition of marks and/or variables in a formula signifies juxtaposition of the sequence denoted.''"
<ref name=ALGOL60RPT>Revised ALGOL 60 report section. 1.1.{{cite web|url=http://www.masswerk.at/algol60/report.htm|title=ALGOL 60|accessdate=April 18, 2015}}</ref>


{{blockquote|Sequences of characters enclosed in the brackets <> represent metalinguistic variables whose values are sequences of symbols. The marks "::{{=}}" and "{{pipe}}" (the latter with the meaning of "or") are metalinguistic connectives. Any mark in a formula, which is not a variable or a connective, denotes itself. Juxtaposition of marks or variables in a formula signifies juxtaposition of the sequence denoted.}}
Another example from the ALGOL 60 report illustrates a major difference of the BNF metalanguage and a Chomsky context sensitive grammar. Metalingustic variables do not require a rule defining their formation. Their formation may simply be described in natural language within the <> brackets. The following ALGOL 60 report section 2.3 comments specification, exemplifies how this works:


Another example from the ALGOL 60 report illustrates a major difference between the BNF metalanguage and a Chomsky context-free grammar. Metalinguistic variables do not require a rule defining their formation. Their formation may simply be described in natural language within the <> brackets. The following ALGOL 60 report section 2.3 comments specification, exemplifies how this works:
<blockquote>
For the purpose of including text among the symbols of a program the following "comment" conventions hold:
For the purpose of including text among the symbols of a program the following "comment" conventions hold:


{|class="wikitable"
{|class="wikitable"
| The sequence of basic symbols:
! The sequence of basic symbols:
| is equivalent to
! is equivalent to
|----
|----
| ; '''comment''' <any sequence not containing ;>;
| ''';''' '''comment''' &lt;any sequence not containing ';'&gt;;
| ;
| ''';'''
|----
|----
| '''begin''' '''comment''' <any sequence not containing ;>;
| '''begin''' '''comment''' &lt;any sequence not containing ';'&gt;;
| '''begin'''
| '''begin'''
|----
|----
| '''end''' <any sequence not containing '''end''' or ; or '''else'''>
| '''end''' &lt;any sequence not containing 'end' or ';' or 'else'&gt;
| '''end'''
| '''end'''
|----
|----
|}
|}


By equivalence is here meant that any of the three structures shown in the left hand column may be replaced, in any occurrence outside of strings, by the symbol shown in the same line in the right hand column without any effect on the action of the program.
Equivalence here means that any of the three structures shown in the left column may be replaced, in any occurrence outside of strings, by the symbol shown in the same line in the right column without any effect on the action of the program.
</blockquote>
(end ALGOL quote)


Naur changed two of Backus's symbols to commonly available characters. The "::=" symbol was originally a ":≡". The "|" symbol was originally the word "{{overline|or}}" (with a bar over it).<ref name="Backus.1969"/>{{rp|14}}
Naur changed two of Backus's symbols to commonly available characters. The <code>::=</code> symbol was originally a <code>:≡</code>. The <code>|</code> symbol was originally the word "{{overline|or}}" (with a bar over it).<ref name="Backus.1969"/>{{rp|14}}


{{clarify|date=April 2015}}Working for IBM, Backus would have had a non-disclosure agreement and couldn't have talked about his source if it came from an IBM proprietary project. BNF is very similar to [[Canonical form (Boolean algebra)|canonical form]] [[boolean algebra]] equations that are, and were at the time, used in logic circuit design. Backus was a mathematician and the designer of the FORTRAN programming language. Studies of boolean algebra is commonly part of a mathematics. What we do know is that neither Backus nor Naur described the names enclosed in < > as non-terminals. Chomsky terminology was not originally used in describing BNF. Naur later described them as classes in ALGOL course materials.<ref name=class/> In the ALGOL 60 report they were called metalinguistic variables. Anything other than the meta symbols ::=, |, and class names in closed in <,> are symbols of the language being defined. The meta symbols ::= is to be interpreted as "is defined as". The | is used to separate alternative definitions and is interpreted as "or". The meta symbols <,> are delimiters enclosing a class name. BNF is described as a [[metalanguage]] for talking about ALGOL by Peter Naur and [[Saul Rosen]].<ref name=class/> In 1947 [[Saul Rosen]] became involved in the activities of the fledgling [[Association for Computing Machinery]], first on the languages committee that became the IAL group and eventually led to ALGOL. He was the first managing editor of the Communications of the ACM.{{clarify|reason=The ACM was founded in 1947. ACM SIGPLAN wasn't founded earlier,.|date=May 2015}} What we do know is that BNF was first used as a metalanguage to talk about the ALGOL language in the ALGOL 60 report. That is how it is explained in ALGOL programming course material developed by Peter Naur in 1962.<ref name=class/> Early ALGOL manuals by IBM, Honeywell, Burroughs and Digital Equipment Corporation followed the ALGOL 60 report using it as a metalanguage. Saul Rosen in his book<ref>{{cite book | author=Saul Rosen | authorlink=Saul Rosen| title=Programming Systems and Languages | location=New York/NY | publisher=McGraw Hill | series=McGraw Hill Computer Science Series |date=Jan 1967 | isbn=0070537089 }}</ref> describes BNF as a metalanguage for talking about ALGOL. An example of its use as a metalanguage would be in defining an arithmetic expression:
BNF is very similar to [[Canonical form (Boolean algebra)|canonical-form]] [[Boolean algebra]] equations that are, and were at the time, used in logic-circuit design. Backus was a mathematician and the designer of the FORTRAN programming language. Studies of Boolean algebra is commonly part of a mathematics curriculum. Neither Backus nor Naur described the names enclosed in <code>&lt; &gt;</code> as non-terminals. Chomsky's terminology was not originally used in describing BNF. Naur later described them as classes in ALGOL course materials.<ref name=class/> In the ALGOL 60 report they were called metalinguistic variables. Anything other than the metasymbols <code>::=</code>, <code>|</code>, and class names enclosed in <code>&lt; &gt;</code> are symbols of the language being defined. The metasymbol <code>::=</code> is to be interpreted as "is defined as". The <code>|</code> is used to separate alternative definitions and is interpreted as "or". The metasymbols <code>&lt; &gt;</code> are delimiters enclosing a class name. BNF is described as a [[metalanguage]] for talking about ALGOL by Peter Naur and [[Saul Rosen]].<ref name=class/>


In 1947 [[Saul Rosen]] became involved in the activities of the fledgling [[Association for Computing Machinery]], first on the languages committee that became the IAL group and eventually led to ALGOL. He was the first managing editor of the Communications of the ACM.{{clarify|reason=The ACM was founded in 1947. ACM SIGPLAN wasn't founded earlier.|date=May 2015}} BNF was first used as a metalanguage to talk about the ALGOL language in the ALGOL 60 report. That is how it is explained in ALGOL programming course material developed by Peter Naur in 1962.<ref name=class/> Early ALGOL manuals by IBM, Honeywell, Burroughs and Digital Equipment Corporation followed the ALGOL 60 report using it as a metalanguage. Saul Rosen in his book<ref>{{cite book | author=Saul Rosen | author-link=Saul Rosen| title=Programming Systems and Languages | location=New York/NY | publisher=McGraw Hill | series=McGraw Hill Computer Science Series |date=Jan 1967 | isbn=978-0070537088 |url=https://archive.org/details/programmingsyste0000unse/mode/1up |url-access=registration}}</ref> describes BNF as a metalanguage for talking about ALGOL. An example of its use as a metalanguage would be in defining an arithmetic expression:
:<source lang=bnf><expr> ::= <term>|<expr><addop><term></source>


{{block indent|1=<syntaxhighlight lang="bnf">
The first symbol of an alternative may be the class being defined. As explained by Naur; The meaning of which is to specify a sequence beginning with a previous alternative.<ref name=class/> For example, above <expr> is defined as a <term> followed by any number of <addop> <term>.
<expr> ::= <term>|<expr><addop><term>
</syntaxhighlight>}}


The first symbol of an alternative may be the class being defined, the repetition, as explained by Naur, having the function of specifying that the alternative sequence can recursively begin with a previous alternative and can be repeated any number of times.<ref name=class/> For example, above <code>&lt;expr&gt;</code> is defined as a <code>&lt;term&gt;</code> followed by any number of <code>&lt;addop&gt; &lt;term&gt;</code>.
In some later metalanguages such Schorre's [[META II]] the BNF recursive repeat construct is replaced by a sequence operator and target language symbols defined using quoted strings. The < and > bracket removed. Mathematical grouping ( ) were added. The <expr> rule would appear in META II as:


In some later metalanguages, such as Schorre's [[META II]], the BNF recursive repeat construct is replaced by a sequence operator and target language symbols defined using quoted strings. The <code>&lt;</code> and <code>&gt;</code> brackets were removed. Parentheses <code>(</code><code>)</code> for mathematical grouping were added. The <code>&lt;expr&gt;</code> rule would appear in META II as
:EXPR = TERM $("+" TERM .out "ADD" | "-" TERM .out "SUB");


{{block indent|1=<syntaxhighlight lang="ebnf">
These changes made META II and its derivative programming languages that are able to define and extend their own metalanguage. In so doing the ability to use a natural language description, meta linguistic variable, language construct description was lost. Many spin-off metalanguages were inspired by BNF. See [[META II]], [[TREE-META]], and [[Metacompiler]].
EXPR = TERM $('+' TERM .OUT('ADD') | '-' TERM .OUT('SUB'));
</syntaxhighlight>}}


These changes enabled META II and its derivative programming languages to define and extend their own metalanguage, at the cost of the ability to use a natural language description, metalinguistic variable, language construct description. Many spin-off metalanguages were inspired by BNF.{{citation needed|date=March 2020}} See [[META II]], [[TREE-META]], and [[Metacompiler]].
A BNF class describes a language construct formation, with formation defined as a pattern or the action of forming the pattern. The class name expr is described in a natural language as a <term> followed by a sequence <addop> <term>. A class is an abstraction we can talk about independent of its formation. We can talk about term, independent of its definition, as being added or subtracted in expr. We can talk about a term being a specific data type and how an expr is to be evaluated having specific combinations of data types. Or even reordering an expression to group data types and evaluation results of mixed types. The natural language supplement provided specific details of the language class semantics to be used by a compiler implementation and a programmer writing an ALGOL program. Natural language description further supplemented the syntax as well. The integer rule is a good example of natural and metalanguage used to describe syntax:


A BNF class describes a language construct formation, with formation defined as a pattern or the action of forming the pattern. The class name expr is described in a natural language as a <code>&lt;term&gt;</code> followed by a sequence <code>&lt;addop&gt; &lt;term&gt;</code>. A class is an abstraction; we can talk about it independent of its formation. We can talk about term, independent of its definition, as being added or subtracted in expr. We can talk about a term being a specific data type and how an expr is to be evaluated having specific combinations of data types, or even reordering an expression to group data types and evaluation results of mixed types. The natural-language supplement provided specific details of the language class semantics to be used by a compiler implementation and a programmer writing an ALGOL program. Natural-language description further supplemented the syntax as well. The integer rule is a good example of natural and metalanguage used to describe syntax:
:<source lang=bnf><integer> ::= <digit>|<integer><digit></source>


{{block indent|<syntaxhighlight lang="bnf">
There are no specifics on white space in the above. As far as the rule states we could have space between the digits. In the natural language we complement the BNF metalanguage by explaining that the digit sequence can have no white space between the digits. English is only one of the possible natural languages. Translations of the ALGOL reports were available in many natural languages.
<integer> ::= <digit>|<integer><digit>
</syntaxhighlight>}}


There are no specifics on white space in the above. As far as the rule states, we could have space between the digits. In the natural language we complement the BNF metalanguage by explaining that the digit sequence can have no white space between the digits. English is only one of the possible natural languages. Translations of the ALGOL reports were available in many natural languages.
The origin of BNF is not as important as its impact on programming language development. During the period immediately following the publication of the ALGOL 60 report BNF was the basis of many [[compiler-compiler]] systems. Some directly used BNF like "A Syntax Directed Compiler for ALGOL 60" developed by E. T. Irons and "A Compiler Building System" Developed by Brooker and Morris. Others changed it to a programming language. The Schorre Metacompilers made it a programming language with only a few changes.. <class name> became symbol identifiers dropping the enclosing <,> and using quoted strings for symbols of the target language. Arithmetic like grouping provided simplification that removed using classes were grouping was its only value. The META II arithmetic expression rule shows grouping use. Output expressions placed in a META II rule are used to output code and labels in an assembly language. Rules in META II are equivalent to a class definitions in BNF. The Unix utility yacc is based on BNF with code production similar to META II. Though yacc is most commonly used as a parser generator its roots are obviously BNF. BNF today is one of the oldest computer related languages still in use.


The origin of BNF is not as important as its impact on programming language development.{{citation needed|date=March 2020}} During the period immediately following the publication of the ALGOL 60 report BNF was the basis of many [[compiler-compiler]] systems.
==Introduction==
A BNF specification is a set of derivation rules, written as
<source lang=bnf>
<symbol> ::= __expression__
</source>


Some, like "A Syntax Directed Compiler for ALGOL 60" developed by Edgar T. Irons and "A Compiler Building System" Developed by Brooker and Morris, directly used BNF. Others, like the Schorre Metacompilers, made it into a programming language with only a few changes. <code>&lt;class name&gt;</code> became symbol identifiers, dropping the enclosing <code>&lt;</code>, <code>&gt;</code> and using quoted strings for symbols of the target language. Arithmetic-like grouping provided a simplification that removed using classes where grouping was its only value. The META II arithmetic expression rule shows grouping use. Output expressions placed in a META II rule are used to output code and labels in an assembly language. Rules in META II are equivalent to a class definitions in BNF. The Unix utility [[yacc]] is based on BNF with code production similar to META II. yacc is most commonly used as a [[parser generator]], and its roots are obviously BNF.
where <[[symbol]]><ref name=class/> is a ''[[nonterminal]]'', and the [[Expression (mathematics)|__expression__]] consists of one or more sequences of symbols; more sequences are separated by the [[vertical bar]], '|', indicating a [[Alternation (formal language theory)|choice]], the whole being a possible substitution for the symbol on the left. Symbols that never appear on a left side are ''[[Terminal symbol|terminal]]s''. On the other hand, symbols that appear on a left side are ''[[Nonterminal symbol|non-terminal]]s'' and are always enclosed between the pair <>.<ref name=class/>


BNF today is one of the oldest computer-related languages still in use.{{citation needed|date=March 2020}}
The '::=' means that the symbol on the left must be replaced with the expression on the right.


==Further examples==
==Example==
As an example, consider this possible BNF for a [[United States|U.S.]] [[Address (geography)|postal address]]:
<source 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> ::= <initial> "." | <first-name>

<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-num> | ""
</source>
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/or initials).
* 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.
* A opt-suffix-part consists of a suffix, such as "Sr.", "Jr." or a [[Roman numerals|roman-numeral]], or an empty string (i.e. nothing).
* A opt-apt-num consists of an apartment number or an empty string (i.e. nothing).


[[File:Bnf-syntax-diagram.png|thumb|alt=BNF syntax diagram |BNF [[syntax diagram]]]]
Note that many things (such as the format of a first-name, apartment specifier, ZIP-code, and Roman numeral) are left unspecified here. If necessary, they may be described using additional BNF rules.


==Further examples==
BNF's syntax itself may be represented with a BNF like the following:
BNF's syntax itself may be represented with a BNF like the following:
<source lang=bnf>
<syntaxhighlight lang="bnf">
<syntax> ::= <rule> | <rule> <syntax>
<syntax> ::= <rule> | <rule> <syntax>
<rule> ::= <opt-whitespace> "<" <rule-name> ">" <opt-whitespace> "::=" <opt-whitespace> <expression> <line-end>
<rule> ::= <opt-whitespace> "<" <rule-name> ">" <opt-whitespace> "::=" <opt-whitespace> <expression> <line-end>
<opt-whitespace> ::= " " <opt-whitespace> | ""
<opt-whitespace> ::= " " <opt-whitespace> | ""
<expression> ::= <list> | <list> "|" <expression>
<expression> ::= <list> | <list> <opt-whitespace> "|" <opt-whitespace> <expression>
<line-end> ::= <opt-whitespace> <EOL> | <line-end> <line-end>
<line-end> ::= <opt-whitespace> <EOL> | <line-end> <line-end>
<list> ::= <term> | <term> <opt-whitespace> <list>
<list> ::= <term> | <term> <opt-whitespace> <list>
<term> ::= <literal> | "<" <rule-name> ">"
<term> ::= <literal> | "<" <rule-name> ">"
<literal> ::= '"' <text> '"' | "'" <text> "'"
<literal> ::= '"' <text1> '"' | "'" <text2> "'"
<text1> ::= "" | <character1> <text1>
</source>
<text2> ::= "" | <character2> <text2>
<character> ::= <letter> | <digit> | <symbol>
<letter> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
<symbol> ::= "|" | " " | "!" | "#" | "$" | "%" | "&" | "(" | ")" | "*" | "+" | "," | "-" | "." | "/" | ":" | ";" | ">" | "=" | "<" | "?" | "@" | "[" | "\" | "]" | "^" | "_" | "`" | "{" | "}" | "~"
<character1> ::= <character> | "'"
<character2> ::= <character> | '"'
<rule-name> ::= <letter> | <rule-name> <rule-char>
<rule-char> ::= <letter> | <digit> | "-"
</syntaxhighlight>


Note that "" is the [[empty string]].
Note that "" is the [[empty string]].


The original BNF did not use quotes as shown in <literal> rule. This assumes that no [[whitespace (computer science)|whitespace]] is necessary for proper interpretation of the rule.
The original BNF did not use quotes as shown in <code>&lt;literal&gt;</code> rule. This assumes that no [[whitespace (computer science)|whitespace]] is necessary for proper interpretation of the rule.


<EOL> represents the appropriate [[newline|line-end]] specifier (in [[ASCII]], carriage-return and/or line-feed, depending on the [[operating system]]). <rule-name> and <text> are to be substituted with a declared rule's name/label or literal text, respectively.
<code>&lt;EOL&gt;</code> represents the appropriate [[newline|line-end]] specifier (in [[ASCII]], carriage-return, line-feed or both depending on the [[operating system]]). <code>&lt;rule-name&gt;</code> and <code>&lt;text&gt;</code> are to be substituted with a declared rule's name/label or literal text, respectively.


In the U.S. postal address example above, the entire block-quote is a syntax. Each line or unbroken grouping of lines is a rule; for example one rule begins with "<name-part> ::=". The other part of that rule (aside from a line-end) is an expression, which consists of two lists separated by a pipe "|". These two lists consists of some terms (three terms and two terms, respectively). Each term in this particular rule is a rule-name.
In the U.S. postal address example above, the entire block-quote is a <code>&lt;syntax&gt;</code>. Each line or unbroken grouping of lines is a rule; for example one rule begins with <code>&lt;name-part&gt; ::=</code>. The other part of that rule (aside from a line-end) is an expression, which consists of two lists separated by a vertical bar <code>|</code>. These two lists consists of some terms (three terms and two terms, respectively). Each term in this particular rule is a rule-name.


==Variants==
==Variants==
There are many variants and extensions of BNF, generally either for the sake of simplicity and succinctness, or to adapt it to a specific application. One common feature of many variants is the use of [[regular expression]] repetition operators such as <code>*</code> and <code>+</code>. The [[Extended Backus–Naur Form]] (EBNF) is a common one. In fact the example above is not the pure form invented for the ALGOL 60 report. The bracket notation "[ ]" was introduced a few years later in [[International Business Machines|IBM]]'s [[PL/I]] definition but is now universally recognised. [[Augmented Backus–Naur Form|ABNF]] and [http://tools.ietf.org/html/rfc5511 RBNF] are other extensions commonly used to describe [[Internet Engineering Task Force|Internet Engineering Task Force (IETF)]] [[Protocol (computing)|protocol]]s.


=== EBNF ===
[[Parsing expression grammar]]s build on the BNF and [[regular expression]] notations to form an alternative class of [[formal grammar]], which is essentially [[analytic grammar|analytic]] rather than [[generative grammar|generative]] in character.
{{Main|Extended Backus–Naur form}}
There are many variants and extensions of BNF, generally either for the sake of simplicity and succinctness, or to adapt it to a specific application. One common feature of many variants is the use of [[regular expression]] repetition operators such as <code>*</code> and <code>+</code>. The [[extended Backus–Naur form]] (EBNF) is a common one.


Another common extension is the use of square brackets around optional items. Although not present in the original ALGOL 60 report (instead introduced a few years later in [[International Business Machines|IBM]]'s [[PL/I]] definition), the notation is now universally recognised.
Many BNF specifications found online today are intended to be human readable and are non-formal. These often include many of the following syntax rules and extensions:


=== ABNF ===
* Optional items enclosed in square brackets: <code>[<item-x>]</code>.
{{Main|ABNF}}
* Items repeating 0 or more times are enclosed in curly brackets or suffixed with an asterisk, <code>*</code>, such as <code><word> ::= <letter> {<letter>}</code> or <code><word> ::= <letter> <letter>*</code>, respectively.
[[Augmented Backus–Naur form]] (ABNF) and Routing Backus–Naur form (RBNF)<ref>[http://tools.ietf.org/html/rfc5511 RBNF].</ref> are extensions commonly used to describe [[Internet Engineering Task Force]] (IETF) [[protocol (computing)|protocol]]s.
* Items repeating 1 or more times are suffixed with an addition (plus) symbol, <code>+</code>.

[[Parsing expression grammar]]s build on the BNF and [[regular expression]] notations to form an alternative class of [[formal grammar]], which is essentially [[analytic grammar|analytic]] rather than [[generative grammar|generative]] in character.

=== Others ===
Many BNF specifications found online today are intended to be human-readable and are non-formal. These often include many of the following syntax rules and extensions:
* Optional items enclosed in square brackets: <code>[&lt;item-x&gt;]</code>.
* Items existing 0 or more times are enclosed in curly brackets or suffixed with an asterisk (<code>*</code>) such as <code>&lt;word&gt; ::= &lt;letter&gt; {&lt;letter&gt;}</code> or <code>&lt;word&gt; ::= &lt;letter&gt; &lt;letter&gt;*</code> respectively.
* Items existing 1 or more times are suffixed with an addition (plus) symbol, <code>+</code>, such as <code>&lt;word&gt; ::= &lt;letter&gt;+</code>.
* Terminals may appear in bold rather than italics, and non-terminals in plain text rather than angle brackets.
* Terminals may appear in bold rather than italics, and non-terminals in plain text rather than angle brackets.
* Where items are grouped, they are enclosed in simple parentheses.
* Where items are grouped, they are enclosed in simple parentheses.


==Software using BNF or variants==
==See also==
* [[Extended Backus–Naur Form]]
* [[Augmented Backus–Naur Form]]
* [[TBNF|Translational Backus-Naur Form]]
* [[Syntax diagram]] (railroad diagram)
* [[Definite clause grammar]], a more expressive alternative to BNF used in [[Prolog]]
* [[Wirth syntax notation]], an alternative to BNF from 1977
* [[Metalanguage]]


===Software using BNF===
=== Software that accepts BNF (or a superset) as input ===
* [[ANTLR]], another parser generator written in [[Java (programming language)|Java]]
* [[ANTLR]], a parser generator written in [[Java (programming language)|Java]]
* [[BNF Converter]] (BNFC<ref>{{Citation | url = http://www.cs.chalmers.se/Cs/Research/Language-technology/BNFC/ | contribution = BNFC | place = [[Sweden|SE]] | publisher = Chalmers | title = Language technology}}</ref>), operating on a variant called Labelled Backus–Naur Form (LBNF). In this variant, each production for a given non-terminal is given a label, which can be used as a constructor of an [[algebraic data type]] representing that nonterminal. The converter is capable of producing types and parsers for [[abstract syntax]] in several languages, including [[Haskell (programming language)|Haskell]] and Java.
* [[Coco/R]], compiler generator accepting an attributed grammar in [[EBNF]]
* [[Coco/R]], compiler generator accepting an attributed grammar in [[EBNF]]
* [[DMS Software Reengineering Toolkit]], program analysis and transformation system for arbitrary languages
* [[DMS Software Reengineering Toolkit]], program analysis and transformation system for arbitrary languages
* [[GOLD (parser)|GOLD]] BNF parser
* [[GOLD (parser)|GOLD]], a BNF parser generator
* RPA BNF parser.<ref>{{Citation | url = http://www.rpatk.net/web/en/onlinedemo.php | title = RPatk | contribution = Online demo | access-date = 2011-07-03 | archive-date = 2012-11-02 | archive-url = https://web.archive.org/web/20121102161746/http://www.rpatk.net/web/en/onlinedemo.php | url-status = dead }}</ref> Online (PHP) demo parsing: JavaScript, XML
* [[GNU bison]], GNU version of yacc
* RPA BNF parser.<ref>{{Citation | url = http://www.rpatk.net/web/en/onlinedemo.php | title = RPatk | contribution = Online demo}}</ref> Online (PHP) demo parsing: JavaScript, XML
* XACT X4MR System,<ref>{{Citation | title = Act world | contribution = Tools | url = http://www.actworld.com/tools/| archive-url = https://web.archive.org/web/20130129075050/http://www.actworld.com/tools/| url-status = dead| archive-date = 2013-01-29}}</ref> a rule-based expert system for programming language translation
* [[XPL]] Analyzer, a tool which accepts simplified BNF for a language and produces a parser for that language in XPL; it may be integrated into the supplied SKELETON program, with which the language may be debugged<ref>If the target processor is System/360, or related, even up to z/System, and the target language is similar to PL/I (or, indeed, XPL), then the required code "emitters" may be adapted from XPL's "emitters" for System/360.</ref> (a [[SHARE (computing)|SHARE]] contributed program, which was preceded by ''A Compiler Generator''<ref>{{cite book |title=A Compiler Generator |first1=W. M. |last1=McKeeman |first2=J.J. |last2=Horning |first3=D. B. |last3=Wortman |year=1970 |publisher=Prentice-Hall |isbn=978-0-13-155077-3 |url=https://archive.org/details/compilergenerato00mcke |url-access=registration}}</ref>)
* XACT X4MR System,<ref>{{Citation | archiveurl = http://web.archive.org/web/20060129221105/http://www.actworld.com/tools/ | archivedate = 2006-01-02 | title = Act world | contribution = Tools | url = http://www.actworld.com/tools/}}</ref> a rule-based expert system for programming language translation
* [[XPL]] Analyzer, a tool which accepts simplified BNF for a language, and which produces a parser for that language in XPL, and which may be integrated into the supplied SKELETON program, with which the language may be debugged<ref>If the target processor is System/360, or related, even up to z/System, and the target language is similar to PL/I (or, indeed, XPL), then the required code "emitters" may be adapted from XPL's "emitters" for System/360.</ref> ([[SHARE (computing)|SHARE]] contributed program, which was preceded by ''A Compiler Generator'', ISBN 978-0-13-155077-3, which see)
* [[Yacc]] parser generator (used with Lex pre-processor)
* bnfparser<sup>2</sup>,<ref>{{Citation | url = http://bnfparser2.sourceforge.net/ | title = Source forge | contribution = BNF parser² | type = project}}</ref> a universal syntax verification utility
* bnfparser<sup>2</sup>,<ref>{{Citation | url = http://bnfparser2.sourceforge.net/ | title = Source forge | contribution = BNF parser² | type = project}}</ref> a universal syntax verification utility
* [http://sourceforge.net/projects/bnf2xml/ bnf2xml] Markup input with XML tags using advanced BNF matching.
* bnf2xml,<ref>[http://sourceforge.net/projects/bnf2xml/ bnf2xml]</ref> Markup input with XML tags using advanced BNF matching
* [https://javacc.java.net/ JavaCC] Java Compiler Compiler tm (JavaCC tm) - The Java Parser Generator
* [[JavaCC]],<ref>{{Cite web |url=https://javacc.java.net/ |title=JavaCC |access-date=2013-09-25 |archive-url=https://web.archive.org/web/20130608172614/https://javacc.java.net/ |archive-date=2013-06-08 |url-status=dead }}</ref> Java Compiler Compiler tm (JavaCC tm) - The Java Parser Generator

===Similar software===
*[[GNU bison]], GNU version of yacc
*[[Yacc]], parser generator (most commonly used with the [[Lex (software)|Lex]] preprocessor)
* Racket's parser tools, lex and yacc-style parsing (Beautiful Racket edition)
*[[Qlik]] Sense, a BI tool, uses a variant of BNF for scripting <ref>{{cite web |title=Script Syntax - Qlik Sense on Windows |url=https://help.qlik.com/en-US/sense/May2021/Subsystems/Hub/Content/Sense_Hub/Scripting/script-syntax.htm |access-date=10 January 2022 |website=Qlik.com |publisher=QlikTech International AB |ref=qlikscriptsyntax}}</ref>
* BNF Converter (BNFC<ref>{{Citation |title=Language technology |url=http://bnfc.digitalgrammars.com/ |contribution=BNFC |place=[[Sweden|SE]] |publisher=Chalmers}}</ref>), operating on a variant called "labeled Backus–Naur form" (LBNF). In this variant, each production for a given non-terminal is given a label, which can be used as a constructor of an [[algebraic data type]] representing that nonterminal. The converter is capable of producing types and parsers for [[abstract syntax]] in several languages, including [[Haskell (programming language)|Haskell]] and Java

==See also==
<!-- Alphabetical -->
* [[Augmented Backus–Naur form]] (ABNF)
* [[Compiler Description Language]] (CDL)
* [[Definite clause grammar]] – a more expressive alternative to BNF used in Prolog
* [[Extended Backus–Naur form]] (EBNF)
* [[Meta-II]] – an early compiler writing tool and notation
* [[Syntax diagram]] – railroad diagram
* [[Translational Backus–Naur form]] (TBNF)
* [[Van Wijngaarden grammar]] – used in preference to BNF to define [[Algol68]]
* [[Wirth syntax notation]] – an alternative to BNF from 1977


==References==
==References==
{{FOLDOC}}
{{Reflist}}
{{reflist}}


==External links==
==External links==
* {{Citation |last = Morrison |first = Kelly | url = http://compilers.iecc.com/comparch/article/93-07-017 | title = comp.compilers (newsgroup) | contribution = Backus Normal Form vs. Backus-Naur Form | publisher = IECC |date=July 2, 1993}} posting quotes Alan J. Perlis and Peter Naur from "ALGOL Section" of Richard L. Wexelblat, editor, ''History of Programming languages'' (1981)
* {{Citation | url = http://www.garshol.priv.no/download/text/bnf.html | title = BNF and EBNF: What are they and how do they work? | first = Lars Marius | last = Garshol | publisher = Priv | place = [[Norway|NO]]}}.
* {{Citation | url = http://www.garshol.priv.no/download/text/bnf.html | title = BNF and EBNF: What are they and how do they work? | first = Lars Marius | last = Garshol | publisher = Priv | place = [[Norway|NO]]}}.
* {{Citation | title = RFC 4234 &mdash; Augmented BNF for Syntax Specifications: ABNF}}.
* {{IETF RFC|5234}} &mdash; Augmented BNF for Syntax Specifications: ABNF.
* {{Citation | title = RFC 5511 &mdash; Routing BNF: A Syntax Used in Various Protocol Specifications}}.
* {{IETF RFC|5511}} &mdash; Routing BNF: A Syntax Used in Various Protocol Specifications.
* ISO/IEC 14977:1996(E) ''Information technology &ndash; Syntactic metalanguage &ndash; Extended BNF'', available from {{Citation | contribution = Publicly available | title = Standards | url = http://standards.iso.org/ittf/PubliclyAvailableStandards/ | publisher = ISO}} or from {{Citation | url = http://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf | first = Marcus | last = Kuhn | publisher = CAM | place = [[United Kingdom|UK]] | title = Iso 14977 | format = PDF}} <small>(the latter is missing the cover page, but is otherwise much cleaner)</small>
* ISO/IEC 14977:1996(E) ''Information technology &ndash; Syntactic metalanguage &ndash; Extended BNF'', available from {{Citation | contribution = Publicly available | title = Standards | url = http://standards.iso.org/ittf/PubliclyAvailableStandards/ | publisher = ISO}} or from {{Citation | url = http://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf | first = Marcus | last = Kuhn | publisher = CAM | place = [[United Kingdom|UK]] | title = Iso 14977 }} <small>(the latter is missing the cover page, but is otherwise much cleaner)</small>


===Language grammars===
===Language grammars===
* {{Citation | url = http://www.lrz-muenchen.de/~bernhard/Algol-BNF.html | title = Algol-60 BNF | publisher = LRZ München | place = [[Germany|DE]] | last = Bernhard}}, the original BNF.
* {{Citation|url=http://blackbox.userweb.mwn.de/Algol-BNF.html |title=Algol-60 BNF |publisher=LRZ München |place=[[Germany|DE]] |last=Bernhard }}, the original BNF.
* {{Citation | url = http://savage.net.au/SQL/ | title = Savage | contribution = BNF grammars for SQL-92, SQL-99 and SQL-2003 | publisher = Net | place = [[Australia|AU]]}}, freely available BNF grammars for [[SQL]].
* {{Citation | url = http://savage.net.au/SQL/ | title = Savage | contribution = BNF grammars for SQL-92, SQL-99 and SQL-2003 | publisher = Net | place = [[Australia|AU]]}}, freely available BNF grammars for [[SQL]].
* {{Citation | url = http://cui.unige.ch/db-research/Enseignement/analyseinfo/BNFweb.html | contribution = BNF Web Club | publisher = Unige | place = [[Switzerland|CH]] | title = DB research}}, freely available BNF grammars for SQL, [[Ada (programming language)|Ada]], [[Java (programming language)|Java]].
* {{Citation | url = http://cui.unige.ch/db-research/Enseignement/analyseinfo/BNFweb.html | contribution = BNF Web Club | publisher = Unige | place = [[Switzerland|CH]] | title = DB research | access-date = 2007-01-25 | archive-url = https://web.archive.org/web/20070124000335/http://cui.unige.ch/db-research/Enseignement/analyseinfo/BNFweb.html | archive-date = 2007-01-24 | url-status = dead }}, freely available BNF grammars for SQL, [[Ada (programming language)|Ada]], [[Java (programming language)|Java]].
* {{Citation | url = http://www.thefreecountry.com/sourcecode/grammars.shtml | contribution = Free Programming Language Grammars for Compiler Construction | title = Source code | publisher = The free country}}, freely available BNF/[[Extended Backus–Naur Form|EBNF]] grammars for C/C++, [[Pascal (programming language)|Pascal]], [[COBOL]], [[Ada (programming language)|Ada 95]], [[PL/I]].
* {{Citation | url = http://www.thefreecountry.com/sourcecode/grammars.shtml | contribution = Free Programming Language Grammars for Compiler Construction | title = Source code | publisher = The free country}}, freely available BNF/[[Extended Backus–Naur form|EBNF]] grammars for C/C++, [[Pascal (programming language)|Pascal]], [[COBOL]], [[Ada (programming language)|Ada 95]], [[PL/I]].
* {{Citation | url = http://exp-engine.svn.sourceforge.net/viewvc/exp-engine/engine/trunk/docs/ | contribution = BNF files related to the STEP standard | title = Exp engine | publisher = Source forge | type = [[Apache Subversion|SVN]]}}. Includes [[List of STEP (ISO 10303) parts|parts 11, 14, and 21]] of the [[ISO 10303]] (STEP) standard.
* {{Citation | url = http://exp-engine.svn.sourceforge.net/viewvc/exp-engine/engine/trunk/docs/ | archive-url = https://archive.today/20121225083955/http://exp-engine.svn.sourceforge.net/viewvc/exp-engine/engine/trunk/docs/ | url-status = dead | archive-date = 2012-12-25 | contribution = BNF files related to the STEP standard | title = Exp engine | publisher = Source forge | type = [[Apache Subversion|SVN]] }}. Includes [[List of STEP (ISO 10303) parts|parts 11, 14, and 21]] of the [[ISO 10303]] (STEP) standard.

{{Metasyntax}}


{{DEFAULTSORT:Backus-Naur Form}}
{{DEFAULTSORT:Backus-Naur Form}}
[[Category:Articles with inconsistent citation formats]]
[[Category:Formal languages]]
[[Category:Formal languages]]
[[Category:Compiler construction]]
[[Category:Compiler construction]]

Latest revision as of 16:09, 30 December 2024

In computer science, Backus–Naur form (BNF; /ˌbækəs ˈnaʊər/; Backus normal form) is a notation used to describe the syntax of programming languages or other formal languages. It was developed by John Backus and Peter Naur. BNF can be described as a metasyntax notation for context-free grammars. Backus–Naur form is applied wherever exact descriptions of languages are needed, such as in official language specifications, in manuals, and in textbooks on programming language theory. BNF can be used to describe document formats, instruction sets, and communication protocols.

Over time, many extensions and variants of the original Backus–Naur notation have been created; some are exactly defined, including extended Backus–Naur form (EBNF) and augmented Backus–Naur form (ABNF).

Overview

[edit]

BNFs describe how to combine different symbols to produce a syntactically correct sequence. BNFs consist of three components: a set of non-terminal symbols, a set of terminal symbols, and rules for replacing non-terminal symbols with a sequence of symbols.[1] These so-called "derivation rules" are written as

 <symbol> ::= __expression__

where:

  • <symbol>[2] is a nonterminal variable that is always enclosed between the pair <>.
  • ::= means that the symbol on the left must be replaced with the expression on the right.
  • __expression__ consists of one or more sequences of either terminal or nonterminal symbols where each sequence is separated by a vertical bar "|" indicating a choice, the whole being a possible substitution for the symbol on the left.

All syntactically correct sequences must be generated in the following manner:

  • Initialize the sequence so that it just contains one start symbol.
  • Apply derivation rules to this start symbol and the ensuing sequences of symbols.[1]

Applying rules in this manner can produce longer and longer sequences, so many BNF definitions allow for a special "delete" symbol to be included in the specification. We can specify a rule that allows us to replace some symbols with this "delete" symbol, which is meant to indicate that we can remove the symbols from our sequence and still have a syntactically correct sequence.[1]

Example

[edit]

As an example, consider this possible BNF for a U.S. postal address:

 <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> | ""

This translates into English as:

  • A postal address consists of a name-part, followed by a street-address part, followed by a zip-code part.
  • A name-part consists of either: a personal-part followed by a last name followed by an optional 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 in BNFs, covering the case of people who use multiple first and middle names and initials).[3]
  • 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 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-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.

History

[edit]

The idea of describing the structure of language using rewriting rules can be traced back to at least the work of Pāṇini, an ancient Indian Sanskrit grammarian and a revered scholar in Hinduism who lived sometime between the 6th and 4th century BC.[4][5] His notation to describe Sanskrit word structure is equivalent in power to that of Backus and has many similar properties.

In Western society, grammar was long regarded as a subject for teaching, rather than scientific study; descriptions were informal and targeted at practical usage. In the first half of the 20th century, linguists such as Leonard Bloomfield and Zellig Harris started attempts to formalize the description of language, including phrase structure.

Meanwhile, string rewriting rules as formal logical systems were introduced and studied by mathematicians such as Axel Thue (in 1914), Emil Post (1920s–40s) and Alan Turing (1936). Noam Chomsky, teaching linguistics to students of information theory at MIT, combined linguistics and mathematics by taking what is essentially Thue's formalism as the basis for the description of the syntax of natural language. He also introduced a clear distinction between generative rules (those of context-free grammars) and transformation rules (1956).[6][7]

John Backus, a programming language designer at IBM, proposed a metalanguage of "metalinguistic formulas"[2][9][10] to describe the syntax of the new programming language IAL, known today as ALGOL 58 (1959). His notation was first used in the ALGOL 60 report.

BNF is a notation for Chomsky's context-free grammars. Backus was familiar with Chomsky's work.[11]

As proposed by Backus, the formula defined "classes" whose names are enclosed in angle brackets. For example, <ab>. Each of these names denotes a class of basic symbols.[2]

Further development of ALGOL led to ALGOL 60. In the committee's 1963 report, Peter Naur called Backus's notation Backus normal form. Donald Knuth argued that BNF should rather be read as Backus–Naur form, as it is "not a normal form in the conventional sense",[12] unlike, for instance, Chomsky normal form. The name Pāṇini Backus form was also once suggested in view of the fact that the expansion Backus normal form may not be accurate, and that Pāṇini had independently developed a similar notation earlier.[13]

BNF is described by Peter Naur in the ALGOL 60 report as metalinguistic formula:[14]

Sequences of characters enclosed in the brackets <> represent metalinguistic variables whose values are sequences of symbols. The marks "::=" and "|" (the latter with the meaning of "or") are metalinguistic connectives. Any mark in a formula, which is not a variable or a connective, denotes itself. Juxtaposition of marks or variables in a formula signifies juxtaposition of the sequence denoted.

Another example from the ALGOL 60 report illustrates a major difference between the BNF metalanguage and a Chomsky context-free grammar. Metalinguistic variables do not require a rule defining their formation. Their formation may simply be described in natural language within the <> brackets. The following ALGOL 60 report section 2.3 comments specification, exemplifies how this works:

For the purpose of including text among the symbols of a program the following "comment" conventions hold:

The sequence of basic symbols: is equivalent to
; comment <any sequence not containing ';'>; ;
begin comment <any sequence not containing ';'>; begin
end <any sequence not containing 'end' or ';' or 'else'> end

Equivalence here means that any of the three structures shown in the left column may be replaced, in any occurrence outside of strings, by the symbol shown in the same line in the right column without any effect on the action of the program.

Naur changed two of Backus's symbols to commonly available characters. The ::= symbol was originally a :≡. The | symbol was originally the word "or" (with a bar over it).[9]: 14 

BNF is very similar to canonical-form Boolean algebra equations that are, and were at the time, used in logic-circuit design. Backus was a mathematician and the designer of the FORTRAN programming language. Studies of Boolean algebra is commonly part of a mathematics curriculum. Neither Backus nor Naur described the names enclosed in < > as non-terminals. Chomsky's terminology was not originally used in describing BNF. Naur later described them as classes in ALGOL course materials.[2] In the ALGOL 60 report they were called metalinguistic variables. Anything other than the metasymbols ::=, |, and class names enclosed in < > are symbols of the language being defined. The metasymbol ::= is to be interpreted as "is defined as". The | is used to separate alternative definitions and is interpreted as "or". The metasymbols < > are delimiters enclosing a class name. BNF is described as a metalanguage for talking about ALGOL by Peter Naur and Saul Rosen.[2]

In 1947 Saul Rosen became involved in the activities of the fledgling Association for Computing Machinery, first on the languages committee that became the IAL group and eventually led to ALGOL. He was the first managing editor of the Communications of the ACM.[clarification needed] BNF was first used as a metalanguage to talk about the ALGOL language in the ALGOL 60 report. That is how it is explained in ALGOL programming course material developed by Peter Naur in 1962.[2] Early ALGOL manuals by IBM, Honeywell, Burroughs and Digital Equipment Corporation followed the ALGOL 60 report using it as a metalanguage. Saul Rosen in his book[15] describes BNF as a metalanguage for talking about ALGOL. An example of its use as a metalanguage would be in defining an arithmetic expression:

<expr> ::= <term>|<expr><addop><term>

The first symbol of an alternative may be the class being defined, the repetition, as explained by Naur, having the function of specifying that the alternative sequence can recursively begin with a previous alternative and can be repeated any number of times.[2] For example, above <expr> is defined as a <term> followed by any number of <addop> <term>.

In some later metalanguages, such as Schorre's META II, the BNF recursive repeat construct is replaced by a sequence operator and target language symbols defined using quoted strings. The < and > brackets were removed. Parentheses () for mathematical grouping were added. The <expr> rule would appear in META II as

EXPR = TERM $('+' TERM .OUT('ADD') | '-' TERM .OUT('SUB'));

These changes enabled META II and its derivative programming languages to define and extend their own metalanguage, at the cost of the ability to use a natural language description, metalinguistic variable, language construct description. Many spin-off metalanguages were inspired by BNF.[citation needed] See META II, TREE-META, and Metacompiler.

A BNF class describes a language construct formation, with formation defined as a pattern or the action of forming the pattern. The class name expr is described in a natural language as a <term> followed by a sequence <addop> <term>. A class is an abstraction; we can talk about it independent of its formation. We can talk about term, independent of its definition, as being added or subtracted in expr. We can talk about a term being a specific data type and how an expr is to be evaluated having specific combinations of data types, or even reordering an expression to group data types and evaluation results of mixed types. The natural-language supplement provided specific details of the language class semantics to be used by a compiler implementation and a programmer writing an ALGOL program. Natural-language description further supplemented the syntax as well. The integer rule is a good example of natural and metalanguage used to describe syntax:

<integer> ::= <digit>|<integer><digit>

There are no specifics on white space in the above. As far as the rule states, we could have space between the digits. In the natural language we complement the BNF metalanguage by explaining that the digit sequence can have no white space between the digits. English is only one of the possible natural languages. Translations of the ALGOL reports were available in many natural languages.

The origin of BNF is not as important as its impact on programming language development.[citation needed] During the period immediately following the publication of the ALGOL 60 report BNF was the basis of many compiler-compiler systems.

Some, like "A Syntax Directed Compiler for ALGOL 60" developed by Edgar T. Irons and "A Compiler Building System" Developed by Brooker and Morris, directly used BNF. Others, like the Schorre Metacompilers, made it into a programming language with only a few changes. <class name> became symbol identifiers, dropping the enclosing <, > and using quoted strings for symbols of the target language. Arithmetic-like grouping provided a simplification that removed using classes where grouping was its only value. The META II arithmetic expression rule shows grouping use. Output expressions placed in a META II rule are used to output code and labels in an assembly language. Rules in META II are equivalent to a class definitions in BNF. The Unix utility yacc is based on BNF with code production similar to META II. yacc is most commonly used as a parser generator, and its roots are obviously BNF.

BNF today is one of the oldest computer-related languages still in use.[citation needed]

Further examples

[edit]
BNF syntax diagram
BNF syntax diagram

BNF's syntax itself may be represented with a BNF like the following:

 <syntax>         ::= <rule> | <rule> <syntax>
 <rule>           ::= <opt-whitespace> "<" <rule-name> ">" <opt-whitespace> "::=" <opt-whitespace> <expression> <line-end>
 <opt-whitespace> ::= " " <opt-whitespace> | ""
 <expression>     ::= <list> | <list> <opt-whitespace> "|" <opt-whitespace> <expression>
 <line-end>       ::= <opt-whitespace> <EOL> | <line-end> <line-end>
 <list>           ::= <term> | <term> <opt-whitespace> <list>
 <term>           ::= <literal> | "<" <rule-name> ">"
 <literal>        ::= '"' <text1> '"' | "'" <text2> "'"
 <text1>          ::= "" | <character1> <text1>
 <text2>          ::= "" | <character2> <text2>
 <character>      ::= <letter> | <digit> | <symbol>
 <letter>         ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
 <digit>          ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
 <symbol>         ::= "|" | " " | "!" | "#" | "$" | "%" | "&" | "(" | ")" | "*" | "+" | "," | "-" | "." | "/" | ":" | ";" | ">" | "=" | "<" | "?" | "@" | "[" | "\" | "]" | "^" | "_" | "`" | "{" | "}" | "~"
 <character1>     ::= <character> | "'"
 <character2>     ::= <character> | '"'
 <rule-name>      ::= <letter> | <rule-name> <rule-char>
 <rule-char>      ::= <letter> | <digit> | "-"

Note that "" is the empty string.

The original BNF did not use quotes as shown in <literal> rule. This assumes that no whitespace is necessary for proper interpretation of the rule.

<EOL> represents the appropriate line-end specifier (in ASCII, carriage-return, line-feed or both depending on the operating system). <rule-name> and <text> are to be substituted with a declared rule's name/label or literal text, respectively.

In the U.S. postal address example above, the entire block-quote is a <syntax>. Each line or unbroken grouping of lines is a rule; for example one rule begins with <name-part> ::=. The other part of that rule (aside from a line-end) is an expression, which consists of two lists separated by a vertical bar |. These two lists consists of some terms (three terms and two terms, respectively). Each term in this particular rule is a rule-name.

Variants

[edit]

EBNF

[edit]

There are many variants and extensions of BNF, generally either for the sake of simplicity and succinctness, or to adapt it to a specific application. One common feature of many variants is the use of regular expression repetition operators such as * and +. The extended Backus–Naur form (EBNF) is a common one.

Another common extension is the use of square brackets around optional items. Although not present in the original ALGOL 60 report (instead introduced a few years later in IBM's PL/I definition), the notation is now universally recognised.

ABNF

[edit]

Augmented Backus–Naur form (ABNF) and Routing Backus–Naur form (RBNF)[16] are extensions commonly used to describe Internet Engineering Task Force (IETF) protocols.

Parsing expression grammars build on the BNF and regular expression notations to form an alternative class of formal grammar, which is essentially analytic rather than generative in character.

Others

[edit]

Many BNF specifications found online today are intended to be human-readable and are non-formal. These often include many of the following syntax rules and extensions:

  • Optional items enclosed in square brackets: [<item-x>].
  • Items existing 0 or more times are enclosed in curly brackets or suffixed with an asterisk (*) such as <word> ::= <letter> {<letter>} or <word> ::= <letter> <letter>* respectively.
  • Items existing 1 or more times are suffixed with an addition (plus) symbol, +, such as <word> ::= <letter>+.
  • Terminals may appear in bold rather than italics, and non-terminals in plain text rather than angle brackets.
  • Where items are grouped, they are enclosed in simple parentheses.

Software using BNF or variants

[edit]

Software that accepts BNF (or a superset) as input

[edit]
  • ANTLR, a parser generator written in Java
  • Coco/R, compiler generator accepting an attributed grammar in EBNF
  • DMS Software Reengineering Toolkit, program analysis and transformation system for arbitrary languages
  • GOLD, a BNF parser generator
  • RPA BNF parser.[17] Online (PHP) demo parsing: JavaScript, XML
  • XACT X4MR System,[18] a rule-based expert system for programming language translation
  • XPL Analyzer, a tool which accepts simplified BNF for a language and produces a parser for that language in XPL; it may be integrated into the supplied SKELETON program, with which the language may be debugged[19] (a SHARE contributed program, which was preceded by A Compiler Generator[20])
  • bnfparser2,[21] a universal syntax verification utility
  • bnf2xml,[22] Markup input with XML tags using advanced BNF matching
  • JavaCC,[23] Java Compiler Compiler tm (JavaCC tm) - The Java Parser Generator

Similar software

[edit]
  • GNU bison, GNU version of yacc
  • Yacc, parser generator (most commonly used with the Lex preprocessor)
  • Racket's parser tools, lex and yacc-style parsing (Beautiful Racket edition)
  • Qlik Sense, a BI tool, uses a variant of BNF for scripting [24]
  • BNF Converter (BNFC[25]), operating on a variant called "labeled Backus–Naur form" (LBNF). In this variant, each production for a given non-terminal is given a label, which can be used as a constructor of an algebraic data type representing that nonterminal. The converter is capable of producing types and parsers for abstract syntax in several languages, including Haskell and Java

See also

[edit]

References

[edit]
  1. ^ a b c Janikow, Cezary Z. "What is BNF?" (PDF).
  2. ^ a b c d e f g The meaning of syntactic formula may be further explained by saying that words enclosed in the brackets < >, like <ab>, denote classes whose members are sequences of basic symbols. Class designations of this kind are found in any description of a language. For describing ordinary natural languages designation like word, verb, noun, are used. .[8]: 5, Note 1 
  3. ^ This article is based on material taken from Backus-Naur+Form at the Free On-line Dictionary of Computing prior to 1 November 2008 and incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.
  4. ^ "Panini biography". School of Mathematics and Statistics, University of St Andrews, Scotland. Retrieved 2014-03-22.
  5. ^ Ingerman, Peter Zilahy (March 1967). ""Pāṇini-Backus Form" Suggested". Communications of the ACM. 10 (3). Association for Computing Machinery: 137. doi:10.1145/363162.363165. S2CID 52817672. Ingerman suggests that the Backus Normal Form be renamed to the Pāṇini-Backus Form, to give due credit to Pāṇini as the earliest independent inventor.
  6. ^ Chomsky, Noam (1956). "Three models for the description of language" (PDF). IRE Transactions on Information Theory. 2 (3): 113–24. doi:10.1109/TIT.1956.1056813. S2CID 19519474. Archived from the original (PDF) on 2010-09-19.
  7. ^ Chomsky, Noam (1957). Syntactic Structures. The Hague: Mouton.
  8. ^ Naur, Peter (1961). "A COURSE OF ALGO L 60 PROGRAMMING with special reference to the DASK ALGOL system" (PDF). Copenhagen: Regnecentralen. Retrieved 26 March 2015.
  9. ^ a b Backus, J. W. (1959). "The syntax and semantics of the proposed international algebraic language of the Zurich ACM-GAMM Conference". Proceedings of the International Conference on Information Processing. UNESCO. pp. 125–132.
  10. ^ Farrell, James A. (August 1995). "Compiler Basics: Extended Backus Naur Form". Archived from the original on 5 June 2011. Retrieved May 11, 2011.
  11. ^ Fulton, III, Scott M. (20 March 2007). "John W. Backus (1924 - 2007)". BetaNews. Inc. Retrieved Jun 3, 2014.
  12. ^ Knuth, Donald E. (1964). "Backus Normal Form vs. Backus Naur Form". Communications of the ACM. 7 (12): 735–736. doi:10.1145/355588.365140. S2CID 47537431.
  13. ^ Ingerman, P. Z. (1967). ""Pāṇini Backus Form" suggested". Communications of the ACM. 10 (3): 137. doi:10.1145/363162.363165. S2CID 52817672.
  14. ^ Revised ALGOL 60 report section. 1.1."ALGOL 60". Retrieved April 18, 2015.
  15. ^ Saul Rosen (Jan 1967). Programming Systems and Languages. McGraw Hill Computer Science Series. New York/NY: McGraw Hill. ISBN 978-0070537088.
  16. ^ RBNF.
  17. ^ "Online demo", RPatk, archived from the original on 2012-11-02, retrieved 2011-07-03
  18. ^ "Tools", Act world, archived from the original on 2013-01-29
  19. ^ If the target processor is System/360, or related, even up to z/System, and the target language is similar to PL/I (or, indeed, XPL), then the required code "emitters" may be adapted from XPL's "emitters" for System/360.
  20. ^ McKeeman, W. M.; Horning, J.J.; Wortman, D. B. (1970). A Compiler Generator. Prentice-Hall. ISBN 978-0-13-155077-3.
  21. ^ "BNF parser²", Source forge (project)
  22. ^ bnf2xml
  23. ^ "JavaCC". Archived from the original on 2013-06-08. Retrieved 2013-09-25.
  24. ^ "Script Syntax - Qlik Sense on Windows". Qlik.com. QlikTech International AB. Retrieved 10 January 2022.
  25. ^ "BNFC", Language technology, SE: Chalmers
[edit]
  • Garshol, Lars Marius, BNF and EBNF: What are they and how do they work?, NO: Priv.
  • RFC 5234 — Augmented BNF for Syntax Specifications: ABNF.
  • RFC 5511 — Routing BNF: A Syntax Used in Various Protocol Specifications.
  • ISO/IEC 14977:1996(E) Information technology – Syntactic metalanguage – Extended BNF, available from "Publicly available", Standards, ISO or from Kuhn, Marcus, Iso 14977 (PDF), UK: CAM (the latter is missing the cover page, but is otherwise much cleaner)

Language grammars

[edit]