📄 4.3.1.1.htm
字号:
<html>
<head>
<title>编译原理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link type="text/css" rel="stylesheet" href="../css/specification.css">
</head>
<BODY>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.3.1.0b.htm'" width="24" height="24"></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.3.1.1b.htm'" width="26" height="24"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>    </td>
<td class="content">
<p><font class="emphasize">消除间接左递归</font></p>
<p>使用这个方法,我们容易把见于表面的所有直接左递归都消除掉,但这并不意味着已经消除整个文法的左递归性。例如文法:</p>
<table align=center width=450 class="content">
<tr><td>S→Aa | b</td><td></td></tr>
<tr><td>A→Ac | Sd|ε</td><td>(4.7)</td></tr>
</table>
<p>非终结符号S是左递归的,因为有S=>Aa=>Sda,但它不是直接左递归的。</p>
<p>算法4.4将彻底地消除一个文法中的左递归。为了确保算法4.4的正常进行,要求文法无环路,即文法中不存在形如A<img src="images/equalplus.gif" width="20" height="19">A的推导;还要求文法无ε-产生式。</p>
<p>
<font class="definition">算法4.4 </font> 消除左递归</p>
<p>输入:无环路无ε- 产生式的文法G。</p>
<p>输出:不带有左递归的一个等价文法。</p>
<p>方法:应用图4.10中的算法到G。注意,所得到的非递归的文法可能含有ε-产生式。</p>
</td></tr></table>
<p>
<center><img src="images/4.10.gif"></center></p>
<table>
<td class="content">
<table align=left>
<td><font class="yanshi">    观看演示 </font></td>
<td>
<font color=blue onmouseover="javascript:style.cursor='hand';" onclick="javascript:open('applet/test4_2/Page1.htm','_blank','left=100,top=100,scrollbars=yes,resizable=yes,width=850,height=600')">消除左递归</font>
</td>
<td><img src="../images/yanshi.gif" width="36" height="35"></img></td>
</table>
</td></tr></table>
</td></tr></table>
<br>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.3.1.0b.htm'" width="24" height="24"></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.3.1.1b.htm'" width="26" height="24"></img></td>
</tr>
</table>
</BODY>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -