📄 4.7.4.2b.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.7.4.2.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.7.4.3.htm'"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>    </td>
<td class="content">
<p>
<font class="example">例4.20 </font>让我们再次考虑拓广文法 <br>
S'→ S <br>
S → L=R|R <br>
L → *R|id <br>
R → L <br>
</p>
<p>对于这个文法的LR(0)项目集的核如图4.24所示。
</p>
</td></tr></table>
<center><img src="images/4.24.gif" width="382" height="231"></center><br>
<center class="content">图4.24 文法4.17的LR(0)项目集的核 </center>
<table><tr><td>  </td>
<td class="content">
<p>现在我们着手为LR(0)项目集的核的每一个项目都配上一个搜索符集,使得这个核成为一个LALR(1)集的核。为了研究搜索符是如何从一个项目集I传播到另一个集合go(I,X)的,让我们考虑在I的核中的一个LR(0)项目B→γ·Cδ。假定规范推导C<img src="images/equalstar.gif" width="20" height="19">Aη 对于某些η成立(可能C=A和η=ε,并且A→xβ是一个产生式,那么,LR(0)项目A→x·β在go(I,X)的核中。</p>
<p>如果所考虑的项目集I是LR(1)集而不是LR(0)集,并且[B→γ·Cδ,b]属于集合I的核。那么对于哪些a的值,[A→X·β,a]将在go(I,X)之核中呢?如果a属于FIRST(ηδ),那么由规范推导C<img src="images/equalstar.gif" width="20" height="19">Aη可知[A→X·β,a]一定在go(I,X)之中。在此情况中b的值是无关的,我们说a,作为A→X·β的一个搜索符,是自生的。由此定义可知,$是作为初态项目集中的项目S'→·S的一个自生的搜索符。</p>
<p>对于项目A→X·β的搜索符的产生还有另一种途径。如果ηδ<img src="images/equalstar.gif" width="20" height="19">ε,那么[A→x·β,a]也将在go(I,X)之中,这个a就是b。在这种情形下,我们说:搜索符a是从B→γ·Cδ传播到A→X·β的。下面的算法用来确定由上述两种方式产生的搜索符。</p>
</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.7.4.2.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.7.4.3.htm'"></img></td>
</tr>
</table>
</BODY>
</html>
<html><script language="JavaScript">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -