﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-HelloWorld 善战者,求之于势,不责于人;故能择人而任势。-随笔分类-编译原理</title><link>http://www.blogjava.net/zhaochengming/category/39604.html</link><description> 知止而后有定，定而后能静，静而后能安，安而后能虑，虑而后能得。物有本末，事有终始。知所先后，则近道矣。</description><language>zh-cn</language><lastBuildDate>Wed, 24 Mar 2010 21:39:58 GMT</lastBuildDate><pubDate>Wed, 24 Mar 2010 21:39:58 GMT</pubDate><ttl>60</ttl><item><title>(#BYYL-3-99) NFA构造DFA的子集算法</title><link>http://www.blogjava.net/zhaochengming/archive/2010/03/21/316084.html</link><dc:creator>helloworld2008</dc:creator><author>helloworld2008</author><pubDate>Sun, 21 Mar 2010 08:17:00 GMT</pubDate><guid>http://www.blogjava.net/zhaochengming/archive/2010/03/21/316084.html</guid><wfw:comment>http://www.blogjava.net/zhaochengming/comments/316084.html</wfw:comment><comments>http://www.blogjava.net/zhaochengming/archive/2010/03/21/316084.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhaochengming/comments/commentRss/316084.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhaochengming/services/trackbacks/316084.html</trackback:ping><description><![CDATA[<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: center"><font  face="宋体" size="6"><span  style="font-size: 21px;"><strong>
<div class="Section0" style="layout-grid:15.6000pt;">
<p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:center; "><span style="mso-spacerun:'yes'; font-weight:bold; font-size:16.0000pt; font-family:'宋体'; ">NFA<font face="宋体">构造DFA的子集算法</font></span><span style="mso-spacerun:'yes'; font-weight:bold; font-size:16.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
<p class="p0" style="margin-left:0.0500pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-weight:bold; font-size:14.0000pt; font-family:'Wingdings'; ">n&nbsp;</span><span style="mso-spacerun:'yes'; font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">输入：一个NFA&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">N</span><span style="mso-spacerun:'yes'; font-weight:bold; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
<p class="p0" style="margin-left:0.0500pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-weight:bold; font-size:14.0000pt; font-family:'Wingdings'; ">n&nbsp;</span><span style="mso-spacerun:'yes'; font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">输出：一个DFA&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">D</span><span style="mso-spacerun:'yes'; font-weight:bold; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
<p class="p0" style="margin-left:0.0500pt; text-indent:21.0000pt; margin-bottom:0pt; margin-top:0pt; "><span style="mso-spacerun:'yes'; font-weight:bold; font-size:14.0000pt; font-family:'Wingdings'; ">n&nbsp;</span><span style="mso-spacerun:'yes'; font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">方法：为D构造一个转换表Dtran。D的每一个状态是一组NFA状态的集合。以下是一些构造需要用到的函数。</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
<table style="border-collapse: collapse; ">
    <tbody>
        <tr>
            <td width="190" valign="top" style="width: 142.6pt; padding-top: 0pt; padding-right: 5.4pt; padding-bottom: 0pt; padding-left: 5.4pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffff99; background-position: initial initial; background-repeat: initial initial; ">
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:center; "><span style="mso-spacerun:'yes'; font-weight:bold; font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">操作</font></span><span style="font-weight:bold; font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            </td>
            <td width="378" valign="top" style="width: 283.5pt; padding-top: 0pt; padding-right: 5.4pt; padding-bottom: 0pt; padding-left: 5.4pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffff99; background-position: initial initial; background-repeat: initial initial; ">
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:center; "><span style="mso-spacerun:'yes'; font-weight:bold; font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">描述</font></span><span style="font-weight:bold; font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            </td>
        </tr>
        <tr>
            <td width="190" valign="top" style="width: 142.6pt; padding-top: 0pt; padding-right: 5.4pt; padding-bottom: 0pt; padding-left: 5.4pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #99cc00; background-position: initial initial; background-repeat: initial initial; ">
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">&#949;</span><span style="mso-spacerun:'yes'; font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">-closure(s)</span><span style="font-weight:bold; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            </td>
            <td width="378" valign="top" style="width: 283.5pt; padding-top: 0pt; padding-right: 5.4pt; padding-bottom: 0pt; padding-left: 5.4pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #99cc00; background-position: initial initial; background-repeat: initial initial; ">
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">能够从NFA的状态s开始只通过</font></span><span style="font-weight:normal; font-size:10.5000pt; font-family:'宋体'; ">&#949;</span><span style="mso-spacerun:'yes'; font-weight:normal; font-size:10.5000pt; font-family:'宋体'; ">转换到达的NFA状态集合</span><span style="font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            </td>
        </tr>
        <tr>
            <td width="190" valign="top" style="width: 142.6pt; padding-top: 0pt; padding-right: 5.4pt; padding-bottom: 0pt; padding-left: 5.4pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ff99cc; background-position: initial initial; background-repeat: initial initial; ">
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">&#949;</span><span style="mso-spacerun:'yes'; font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">-closure(T)</span><span style="font-weight:bold; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            </td>
            <td width="378" valign="top" style="width: 283.5pt; padding-top: 0pt; padding-right: 5.4pt; padding-bottom: 0pt; padding-left: 5.4pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ff99cc; background-position: initial initial; background-repeat: initial initial; ">
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="color:rgb(128,0,0); font-size:22.0000pt; font-family:'宋体'; ">U</span><span style="mso-spacerun:'yes'; color:rgb(0,51,0); font-size:22.0000pt; font-family:'宋体'; vertical-align:sub; ">sє</span><span style="color:rgb(0,51,0); font-size:15.0000pt; font-family:'宋体'; vertical-align:sub; ">T</span><span style="mso-spacerun:'yes'; color:rgb(0,0,255); font-weight:bold; font-size:22.0000pt; font-family:'宋体'; ">&#949;-closure(s)</span><span style="font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            </td>
        </tr>
        <tr>
            <td width="190" valign="top" style="width: 142.6pt; padding-top: 0pt; padding-right: 5.4pt; padding-bottom: 0pt; padding-left: 5.4pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffcc00; background-position: initial initial; background-repeat: initial initial; ">
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">move(T,a)</span><span style="font-weight:bold; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            </td>
            <td width="378" valign="top" style="width: 283.5pt; padding-top: 0pt; padding-right: 5.4pt; padding-bottom: 0pt; padding-left: 5.4pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffcc00; background-position: initial initial; background-repeat: initial initial; ">
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">能够从T中某个状态S出发通过标号为a的转换到达的NFA状态的集合</font></span><span style="font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            </td>
        </tr>
    </tbody>
</table>
<p class="p0" style="margin-left:21.0500pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-weight:bold; font-size:14.0000pt; font-family:'Wingdings'; ">&#216;&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">构造D的状态集合DStates和D的转换函数Dtran</span><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
<table style="border-collapse: collapse; ">
    <tbody>
        <tr>
            <td width="568" valign="top" style="width: 426.1pt; padding-top: 0pt; padding-right: 5.4pt; padding-bottom: 0pt; padding-left: 5.4pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ccffcc; background-position: initial initial; background-repeat: initial initial; ">
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">一开始,</font></span><span style="mso-spacerun:'yes'; color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">&#949;-closure(s)</span><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">是DStates中的唯一状态，且没有被标记;</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; ">while&nbsp;(DStates<font face="宋体">中存在未被标识的状态T)&nbsp;{</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">标识T;</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; ">for(<font face="宋体">每个输入符号a)&nbsp;{</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:42.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; ">U&nbsp;=&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">&#949;-closure(</span><span style="mso-spacerun:'yes'; color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">move(T,a)</span><span style="color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">)</span><span style="color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">;</span><span style="color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:42.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-weight:normal; font-size:10.5000pt; font-family:'宋体'; ">if(U不再DStats中)&nbsp;将U加入DStates，且没有标识;</span><span style="color:rgb(0,0,128); font-weight:normal; font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:42.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-weight:normal; font-size:10.5000pt; font-family:'宋体'; ">Dtran[T,a]&nbsp;=&nbsp;U;</span><span style="color:rgb(0,0,128); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; ">}</span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; ">}</span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            </td>
        </tr>
    </tbody>
</table>
<p class="p0" style="margin-left:42.0000pt; text-indent:-21.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(51,51,153); font-size:14.0000pt; font-family:'Wingdings'; ">&#216;&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(51,51,153); font-size:14.0000pt; font-family:'宋体'; ">计算</span><span style="mso-spacerun:'yes'; color:rgb(51,51,153); font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">&#949;-closure(T)的算法</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
<table style="border-collapse: collapse; ">
    <tbody>
        <tr>
            <td width="568" valign="top" style="width: 426.1pt; padding-top: 0pt; padding-right: 5.4pt; padding-bottom: 0pt; padding-left: 5.4pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ccffcc; background-position: initial initial; background-repeat: initial initial; ">
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">将T的所有状态压入堆栈中;</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">将</font></span><span style="mso-spacerun:'yes'; color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">&#949;-closure(</span><span style="color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">T</span><span style="color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">)</span><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">的内容初始化为T;</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; ">while&nbsp;(<font face="宋体">堆栈非空)&nbsp;{</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">将栈顶元素t弹出;</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; ">for(<font face="宋体">每个满足如下条件的u：从t出发有一个标号为</font></span><span style="color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">&#949;</span><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">的转换到达状态u)</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:42.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; ">if(u<font face="宋体">不再</font></span><span style="mso-spacerun:'yes'; color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">&#949;-closure(</span><span style="color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">T</span><span style="color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">)</span><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">中){</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:63.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">将u加入到</font></span><span style="mso-spacerun:'yes'; color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">&#949;-closure(</span><span style="color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">T</span><span style="color:rgb(153,51,0); font-weight:bold; font-size:10.5000pt; font-family:'宋体'; ">)</span><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">中;</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:63.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">将u压入栈中;</font></span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:42.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; ">}</span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; ">}</span><span style="color:rgb(0,0,128); font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            </td>
        </tr>
    </tbody>
</table>
<p class="p0" style="margin-left:42.0000pt; text-indent:-21.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'Wingdings'; ">&#216;&nbsp;</span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; "><font face="宋体">附模拟一个NFA</font></span><span style="mso-spacerun:'yes'; font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
<table style="border-collapse: collapse; ">
    <tbody>
        <tr>
            <td width="568" valign="top" style="width: 426.1pt; padding-top: 0pt; padding-right: 5.4pt; padding-bottom: 0pt; padding-left: 5.4pt; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ccffcc; background-position: initial initial; background-repeat: initial initial; ">
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; ">S&nbsp;=&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(153,51,0); font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">&#949;-closure(s</span><span style="color:rgb(153,51,0); font-weight:bold; font-size:14.0000pt; font-family:'宋体'; vertical-align:sub; ">0</span><span style="mso-spacerun:'yes'; color:rgb(153,51,0); font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">);</span><span style="color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; ">c&nbsp;=&nbsp;nextChar();</span><span style="color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; ">while(c&nbsp;!=&nbsp;eof)&nbsp;{</span><span style="color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; ">S&nbsp;=&nbsp;</span><span style="mso-spacerun:'yes'; color:rgb(153,51,0); font-weight:bold; font-size:14.0000pt; font-family:'宋体'; ">&#949;-closure(move(S,c))</span><span style="color:rgb(153,51,0); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; ">;</span><span style="color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-left:21.0000pt; margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; ">c&nbsp;=&nbsp;nextChar();</span><span style="color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; ">}</span><span style="color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; ">if(S&nbsp;&#8745;&nbsp;F&nbsp;!=&nbsp;&#248;)&nbsp;return&nbsp;true;</span><span style="color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            <p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(51,51,153); font-weight:normal; font-size:14.0000pt; font-family:'宋体'; ">else&nbsp;return&nbsp;false;</span><span style="font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
            </td>
        </tr>
    </tbody>
</table>
<p class="p0" style="margin-bottom:0pt; margin-top:0pt; text-align:justify; "><span style="mso-spacerun:'yes'; color:rgb(51,51,153); font-weight:normal; font-size:10.5000pt; font-family:'宋体'; "><o:p></o:p></span></p>
</div>
</strong></span></font><br />
</p>
<img src ="http://www.blogjava.net/zhaochengming/aggbug/316084.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhaochengming/" target="_blank">helloworld2008</a> 2010-03-21 16:17 <a href="http://www.blogjava.net/zhaochengming/archive/2010/03/21/316084.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>文法的化简与改造</title><link>http://www.blogjava.net/zhaochengming/archive/2009/07/06/285613.html</link><dc:creator>helloworld2008</dc:creator><author>helloworld2008</author><pubDate>Sun, 05 Jul 2009 16:45:00 GMT</pubDate><guid>http://www.blogjava.net/zhaochengming/archive/2009/07/06/285613.html</guid><wfw:comment>http://www.blogjava.net/zhaochengming/comments/285613.html</wfw:comment><comments>http://www.blogjava.net/zhaochengming/archive/2009/07/06/285613.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhaochengming/comments/commentRss/285613.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhaochengming/services/trackbacks/285613.html</trackback:ping><description><![CDATA[<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">文法的化简与改造</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">1、无用符号及无用产生式的删除&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">无用符号：设有一文法G[S]=&nbsp;（V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，P，S），说G中的一个符号X&#8712;V是有用的是指X至少出现在一个句子的推导过程中，即满足：</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">存在&#945;，&#946;&#8712;V*，有S=*&gt;&#945;X&#946;&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">存在&#969;&#8712;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">*&nbsp;，&#945;X&#946;=*&gt;&#969;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">否则X为无用符号</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">设有文法G[S]=&nbsp;（V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，P，S），首先用算法2.1改造该文法的到G1[S]=&nbsp;（V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，P</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">，S），使得对于每一个X&#8712;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">，都有&#969;&#8712;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">*，X=*&gt;&#969;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(255,0,0); font-family: '宋体'; mso-spacerun: 'yes'">算法1：&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(1)&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">分别置V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">，P</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">为&#934;。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(2)&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">对P中每一个产生式A&#8594;&#948;，若&#948;&#8712;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">*，则将A放入V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">中。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(3)&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">对P中每一个产生式A&#8594;X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8230;&#8230;X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">，若每一个X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;都属于V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">或V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">，则将A放入V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">中。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(4)&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">重复③直至V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">不增大。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(5)&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">对于P中的每一个产生式B&#8594;Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8230;&#8230;Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">n</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，若B及每一个Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，都属于V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8746;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;&nbsp;，则将B&#8594;Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8230;&#8230;Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">n</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">，放入P</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">中。&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">其次，对以给文法G[S]，若执行算法2.2可得到一等价文法G&#8217;=（V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;，&nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;&nbsp;，P&#8217;，S）使得对任一X&#8712;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;&#8746;&nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;都存在&#945;，&#946;&#8712;（V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;&#8746;&nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;）有S=*&gt;&#945;X&#946;.&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(255,0,0); font-family: '宋体'; mso-spacerun: 'yes'">算法2:</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">1.分别置V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;、&nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;、P&#8217;为&#966;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">2.将S&nbsp;放入V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;中。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">3.对于G中任何型如A&#8594;&#945;</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">|&#8230;&#8230;|&#945;</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">m</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">的产生式，若A&#8712;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;则将&#945;</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8230;&#8230;&#945;</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">m</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;中的全部非终结符放入V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;中，终结符放入V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;中。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">4.重复③直至V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;、&nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;不增大为止。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">5.将P中左右部仅含V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;&#8746;&nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8217;中符号的所有产生式放入P&#8217;&nbsp;中。&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">2、&#949;—产生式的消除</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">有的分析方法要求文法中不能含有&#949;—产生式，因此需要改造文法使之不含&#949;—产生式。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">如果语言不含有&#949;句子，则可有办法消除文法中的全部&#949;—产生式，否则不可能全部消除，但我们希望只有在空句子的推导中用到&#949;—产生式，其他语句的推导过程中不会使用&#949;—产生式。故对含有空句子的文法，我们希望只有文法开始符S&#8594;&#949;这样一个产生式并且S不出现在其它任何产生式的右部。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(255,0,0); font-family: '宋体'; mso-spacerun: 'yes'">算法3：</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">找出所有能导出&#949;的非终结符。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">1.构造W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">={A|产生式A&#8594;&#949;&#8712;P}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">2.构造集合序列W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K+1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">=&nbsp;W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8746;{B|B&#8594;&#946;&#8712;P，且&#946;&#8712;W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">，K&#8805;1}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;&nbsp;W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K+1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">是一个有限集，设最后的W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K+1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">为W。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">当S&#8712;W时，&#949;&#8712;L（G[S]）。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">设有一文法G[S]=&nbsp;（V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，P，S），当&#949;不属于该文法所描述的语言时，可构造文法：</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">G&#8217;=（V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">，V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">，P&#8217;，S），使得L（G&#8217;）=L（G），G&#8217;不含有&#949;产生式：</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(255,0,0); font-family: '宋体'; mso-spacerun: 'yes'">算法4:</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">1.利用W将V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;分为两个子集W及V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;-W。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">2.设A&#8594;X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8230;&#8230;X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8712;P，按下面规则将所有型如A&#8594;Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&#8230;&#8230;Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;的产生式放入P&#8217;中，对于一切1&#8804;i&#8804;k：</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;&nbsp;a．若X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;不属于W，则取Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;=&nbsp;X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">b．若X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;&#8712;W，则分别取Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;为X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">与&#949;，但是若所有X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">均属于W，却不能把所有Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;取为&#949;。&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">设有一文法G[S]=&nbsp;（V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，P，S），当&#949;属于该文法所描述的语言时，可构造文法：</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">G1=（V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，P</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">，S&#8217;），使得L（G</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">）=L（G），P</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">中除S&#8217;&#8594;&#949;外不再含有其它&#949;产生式，并且S&#8217;不出现在任何产生式的右边。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(255,0,0); font-family: '宋体'; mso-spacerun: 'yes'">算法5：</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">若S不出现在任何产生式的右部，则可直接用算法2.4消除&#949;产生式，再加入S&#8594;&#949;，否则：</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;&nbsp;1．引入新的非终结符S&#8217;，&nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">=&nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;&#8746;{&nbsp;S&#8217;}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;&nbsp;2．构造P&#8217;&nbsp;=P&#8746;{&nbsp;S&#8217;&#8594;&#945;|&nbsp;S&#8594;&#945;&#8712;P}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;&nbsp;3．对文法G1=（V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">1&nbsp;，V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;，P</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">，S&#8217;），执行算法4，再加入S&#8217;&#8594;&#949;。&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">3、单产生式的消除</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">A&#8594;B，A,B&#8712;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;此类产生式被称为单产生式。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">假定文法中不含有&#949;产生式。</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">算法6：</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">设V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;={&nbsp;A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;......&nbsp;A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;}&nbsp;对每一个A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;（1&#8804;i&#8804;n）构造集合序列</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(&nbsp;A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">）={A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">}，&nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K+1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">（A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;）=&nbsp;W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">（A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;）&#8746;{D|C&#8594;D&#8712;P，C&#8712;W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">（A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;），D&#8712;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">K&#8805;1，该集合序列存在一个j，有</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">j</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">（A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;）=&nbsp;W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">j+1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">（A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;）......</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">令W（i）=&nbsp;W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">j</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">（A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;）</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">W（i）={B|&nbsp;A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;=&gt;B，B&#8712;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">构造P&#8217;={&nbsp;A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">&nbsp;&#8594;&#945;|B&#8594;&#945;&#8712;P，B&#8712;W（i），&#945;不是单个非终结符}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(</span><span style="font-weight: normal; font-size: 14pt; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">对于A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">到A<sub>n</sub>的U操作</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">),</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">此时P&#8242;中已不含任何单产生式。</span></p>
<!--endfragment-->
 <img src ="http://www.blogjava.net/zhaochengming/aggbug/285613.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhaochengming/" target="_blank">helloworld2008</a> 2009-07-06 00:45 <a href="http://www.blogjava.net/zhaochengming/archive/2009/07/06/285613.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>编译原理第二章中缀转后缀java版</title><link>http://www.blogjava.net/zhaochengming/archive/2009/05/15/270944.html</link><dc:creator>helloworld2008</dc:creator><author>helloworld2008</author><pubDate>Fri, 15 May 2009 14:20:00 GMT</pubDate><guid>http://www.blogjava.net/zhaochengming/archive/2009/05/15/270944.html</guid><wfw:comment>http://www.blogjava.net/zhaochengming/comments/270944.html</wfw:comment><comments>http://www.blogjava.net/zhaochengming/archive/2009/05/15/270944.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhaochengming/comments/commentRss/270944.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhaochengming/services/trackbacks/270944.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 刚刚学习编译原理，这是第二章的代码的改写，源码http://www.blogjava.net/Files/zhaochengming/compiler%20section%202%20parse.rar1.KeyWord.java 关键字对象类package&nbsp;parse;public&nbsp;class&nbsp;KeyWord&nbsp;{&nbsp;&n...&nbsp;&nbsp;<a href='http://www.blogjava.net/zhaochengming/archive/2009/05/15/270944.html'>阅读全文</a><img src ="http://www.blogjava.net/zhaochengming/aggbug/270944.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhaochengming/" target="_blank">helloworld2008</a> 2009-05-15 22:20 <a href="http://www.blogjava.net/zhaochengming/archive/2009/05/15/270944.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>