<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>随网之舞铁路图</title>
	<atom:link href="http://dancewithnet.com/tag/%e9%93%81%e8%b7%af%e5%9b%be/feed/" rel="self" type="application/rss+xml" />
	<link>http://dancewithnet.com</link>
	<description>WEB Design{HTML:CSS:Javascript:DOM:AJAX:PHP:Usability}/Viewpoint/Photo/Food/Mood</description>
	<lastBuildDate>Mon, 18 Jul 2011 02:45:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>语法图</title>
		<link>http://dancewithnet.com/2008/05/28/syntax-diagrams/</link>
		<comments>http://dancewithnet.com/2008/05/28/syntax-diagrams/#comments</comments>
		<pubDate>Wed, 28 May 2008 15:45:13 +0000</pubDate>
		<dc:creator>秦歌</dc:creator>
				<category><![CDATA[web2.0 & so on]]></category>
		<category><![CDATA[BNF]]></category>
		<category><![CDATA[EBNF]]></category>
		<category><![CDATA[巴科斯范式]]></category>
		<category><![CDATA[语法]]></category>
		<category><![CDATA[语法图]]></category>
		<category><![CDATA[铁路图]]></category>

		<guid isPermaLink="false">http://dancewithnet.com/?p=1302</guid>
		<description><![CDATA[语法图（Syntax diagrams ）又叫铁路图（railroad diagrams）是描述形式文法的一种方式。它是巴科斯范式或扩展巴科斯范式的图形化表示。最早使用语法图的书包括Niklaus Wirth写的&#8220;Pascal User Manual&#8... ]]></description>
			<content:encoded><![CDATA[<p>语法图（Syntax diagrams ）又叫铁路图（railroad diagrams）是描述<a href="http://zh.wikipedia.org/wiki/%E5%BD%A2%E5%BC%8F%E6%96%87%E6%B3%95">形式文法</a>的一种方式。它是<a href="http://dancewithnet.com/2008/05/17/bnf-and-ebnf/">巴科斯范式或扩展巴科斯范式</a>的图形化表示。最早使用语法图的书包括Niklaus Wirth写的<a href="http://www.standardpascal.org/The_Programming_Language_Pascal_1973.pdf">&#8220;Pascal User Manual&#8221;</a>（语法图开始于47页）和<a href="http://bitsavers.org/pdf/burroughs/B6500_6700/5000318_B6700_CANDE_Oct72.pdf">the Burroughs CANDE manual</a>。在编译领域，像BNF和它的变体这样的文字式表示法都是首选的。BNF能很好的被编译器作者和编译器理解，但是不能很好的被这些语言的大部分用户理解。铁路图能更容易被大多数人理解。数据交换格式<a href="http://zh.wikipedia.org/wiki/JSON">JSON</a>之所以流行的部分原因就是它用铁路图来表示。<span id="more-1302"></span></p>
<h3>准则</h3>
<p>一个语法的表示法是由一套语法图组成。每个图定义了一个非终结符。有一个主图通过下面方式定义了这门语言：属于这门语言的每句话都必须在主图上描绘一个路径。</p>
<p>每个图都有一个起始点和一个终点。这个图通过穿过其他的非终结符和终结符描绘了这些两点之间的可能路径。终结符用圆形区域表示，同时非终结符用方形区域表示。</p>
<h3>例子</h3>
<p>我们用一个算术表达式作为一个例子。首先我们提供一段简单的BNF语法：</p>
<pre><code>&lt;expression&gt;::= &lt;term&gt; | &lt;term&gt; &quot;+&quot; &lt;expression&gt;
&lt;term&gt;::= &lt;factor&gt; | &lt;factor&gt; &quot;*&quot; &lt;term&gt;
&lt;factor&gt;::= &lt;constant&gt; | &lt;variable&gt; | &quot;(&quot; &lt;expression&gt; &quot;)&quot;
&lt;variable&gt;::= &quot;x&quot; | &quot;y&quot; | &quot;z&quot;
&lt;constant&gt;::= &lt;digit&gt; | &lt;digit&gt; &lt;constant&gt;
&lt;digit&gt;::= &quot;0&quot; | &quot;1&quot; | &quot;2&quot; | &quot;3&quot; | &quot;4&quot; | &quot;5&quot; | &quot;6&quot; | &quot;7&quot; | &quot;8&quot; | &quot;9&quot;</code></pre>
<p>这段语法也能在EBNF中被表示：</p>
<pre><code>expression = term , {"+" term};
term = factor , {"*" factor};
factor = constant | variable | "(" , expression , ")";
variable = "x" | "y" | "z";
constant = digit , {digit};
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
</code></pre>
<p>关于这段语法的一组可能的语法图：<img src="http://dancewithnet.com/wp-content/uploads/2008/05/syntax-diagrams.png" alt="" title="syntax-diagrams" width="500" height="573" class="alignnone size-full wp-image-1303" /></p>
<h3>扩展链接</h3>
<ol>
<li><a href="http://dancewithnet.com/2008/05/17/bnf-and-ebnf/">巴科斯范式和扩展巴科斯范式</a></li>
<li><a href="http://www.json.org/json-zh.html">JSON website including syntax diagrams</a></li>
<li> <a href="http://www-cgi.uni-regensburg.de:80/~brf09510/syntax.html">Automatic generator of syntax diagrams</a></li>
<li><a href="http://www-cgi.uni-regensburg.de:80/~brf09510/syntax/lazyebnf.ebnf.html">Syntax diagrams of BNF</a></li>
<li><a href="http://dotnet.jku.at/applications/Visualizer/">Generator from EBNF</a></li>
<li><a href="http://www.informatik.uni-freiburg.de:80/~thiemann/haskell/ebnf2ps/">From EBNF to a postscript file wit the diagrams</a></li>
</ol>
<p>原文：<a href="http://en.wikipedia.org/wiki/Syntax_diagram">Syntax diagram</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dancewithnet.com/2008/05/28/syntax-diagrams/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

