📄 4.7.2.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.7.2.0b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.7.2.1b.htm'"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>    </td>
<td class="content">
<p>
<img class="dingyi" src="../images/dingyi.gif">
<font class="definition2">定义4.10</font>若I是G的一个LR(0)项目集,X是一个文法符号,定义 <br>
         go(I,X)=closure(J) <br>
    其中<br>
         J={A→αX·β|当A→α·Xβ属于I时} <br>
    go(I,X)称为转移函数。项目A→αX·β称为A→α·Xβ的后继。</p>
<p>若I中项目A→α·Xβ是某个活前缀γ=δα 的有效项目,根据定义4.7有规范推导 </p>
<p>S <img src="images/equalstar.gif" width="20" height="19"> δAw <img src="images/equal.gif"> δαXβw </p>
<p>上述规范推导也同时说明J中项目A→αX·β是活前缀γX的有效项目。所以直观上说若I是某个活前缀γ的有效项目集,则go(I,X)便是对γX的有效项目集。</p>
<p>求项目集的闭包closure(I)和计算项目集的转移函数Go(I,x)是计算文法G的LR(0)项目集规范族的基本运算,它们由算法4.8给出:</p>
<p><font class="definition"><img border="0" src="images/dingyi.gif" width="32" height="31">算法4.8 </font>计算closure(I)和Go(I,x) <br>
<font color="#0000FF">FUNCTION</font> closure(I:SET OF
item):<font color="#0000FF">SET OF</font> item; <br>
<font color="#0000FF">BEGIN</font> <br>
<font color="#0000FF">REPEAT</font> <br>
<font color="#0000FF">FOR</font> 任一A→α·Bβ
<font color="#0000FF"> IN</font> I <br>
<font color="#0000FF">FOR</font> 任一B→η
<font color="#0000FF"> IN</font> P <br>
I:=I∪{B→·η} <br>
<font color="#0000FF">UNTIL</font> I不再增大 <br>
<font color="#0000FF">Return</font> (I) <br>
<font color="#0000FF">END</font>; <br>
<br>
<font color="#0000FF">FUNCTION</font> Go(I:SET OF item; x∈{V<sub>T</sub>∪V<sub>N</sub>}):<font color="#0000FF">SET OF</font> item; <br>
<font color="#0000FF">VAR</font> J:<font color="#0000FF">SET OF</font> item; <br>
<font color="#0000FF">BEGIN</font> <br>
J:={ }; <br>
<font color="#0000FF">FOR</font> 任一A→α·Xβ
<font color="#0000FF"> IN</font> I <br>
J:=J∪{A→αX·β} <br>
<font color="#0000FF">Return</font> (closure(J)) <br>
<font color="#0000FF">END</font>;
</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.2.0b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.7.2.1b.htm'"></img></td>
</tr>
</table>
</BODY>
</html>
<html><script language="JavaScript">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -