JargonFile/original/html/B/BNF.html
2014-03-27 18:54:56 +00:00

41 lines
4.5 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>BNF</title><link rel="stylesheet" href="../../jargon.css" type="text/css"/><meta name="generator" content="DocBook XSL Stylesheets V1.61.0"/><link rel="home" href="../index.html" title="The Jargon File"/><link rel="up" href="../B.html" title="B"/><link rel="previous" href="blurgle.html" title="blurgle"/><link rel="next" href="boa.html" title="boa"/></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">BNF</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="blurgle.html">Prev</a> </td><th width="60%" align="center">B</th><td width="20%" align="right"> <a accesskey="n" href="boa.html">Next</a></td></tr></table><hr/></div><dt><a id="BNF"/><dt xmlns="" id="BNF"><b>BNF</b>: <span xmlns="http://www.w3.org/1999/xhtml" class="pronunciation">/B·N·F/</span>, <span xmlns="http://www.w3.org/1999/xhtml" class="grammar">n.</span></dt></dt><dd><p> 1. [techspeak] Acronym for <span class="firstterm">Backus Normal
Form</span> (later retronymed to <span class="firstterm">Backus-Naur
Form</span> because BNF was not in fact a normal form), a metasyntactic
notation used to specify the syntax of programming languages, command sets,
and the like. Widely used for language descriptions but seldom documented
anywhere, so that it must usually be learned by osmosis from other hackers.
Consider this BNF for a U.S. postal address:</p><div class="literallayout"><p><br/>
 &lt;postal-address&gt; ::= &lt;name-part&gt; &lt;street-address&gt; &lt;zip-part&gt;<br/>
<br/>
 &lt;personal-part&gt; ::= &lt;name&gt; | &lt;initial&gt; &quot;.&quot;<br/>
<br/>
 &lt;name-part&gt; ::= &lt;personal-part&gt; &lt;last-name&gt; [&lt;jr-part&gt;] &lt;EOL&gt;<br/>
               | &lt;personal-part&gt; &lt;name-part&gt;<br/>
<br/>
 &lt;street-address&gt; ::= [&lt;apt&gt;] &lt;house-num&gt; &lt;street-name&gt; &lt;EOL&gt;<br/>
<br/>
 &lt;zip-part&gt; ::= &lt;town-name&gt; &quot;,&quot; &lt;state-code&gt; &lt;ZIP-code&gt; &lt;EOL&gt;<br/>
</p></div><p>This translates into English as: &#8220;<span class="quote">A postal-address consists of
a name-part, followed by a street-address part, followed by a zip-code
part. A personal-part consists of either a first name or an initial
followed by a dot. A name-part consists of either: a personal-part
followed by a last name followed by an optional jr-part (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/or initials). A
street address consists of an optional apartment specifier, followed by a
street number, followed by a street name. 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.</span>&#8221; Note that many things (such as
the format of a personal-part, apartment specifier, or ZIP-code) are left
unspecified. These are presumed to be obvious from context or detailed
somewhere nearby. See also <a href="../P/parse.html"><i class="glossterm">parse</i></a>.</p></dd><dd><p> 2. Any of a number of variants and extensions of BNF proper,
possibly containing some or all of the <a href="../R/regexp.html"><i class="glossterm">regexp</i></a>
wildcards such as <b class="command">*</b> or <b class="command">+</b>. In fact the example above isn't the pure form
invented for the Algol-60 report; it uses <b class="command">[]</b>, which was introduced a few years later in IBM's
PL/I definition but is now universally recognized. </p></dd><dd><p> 3. In <a href="../S/science-fiction-fandom.html"><i class="glossterm">science-fiction fandom</i></a>, a
&#8216;Big-Name Fan&#8217; (someone famous or notorious). Years ago a fan
started handing out black-on-green BNF buttons at SF conventions; this
confused the hacker contingent terribly.</p></dd><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="blurgle.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="../B.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="boa.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">blurgle </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> boa</td></tr></table></div></body></html>