📄 4.7.2.5.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.4b.htm'" width="24" height="24"></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.7.2.5b.htm'" width="26" height="24"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>    </td>
<td class="content">
<p>现在让我们根据算法4.9来构造文法(4.16)的SLR分析表。考虑项目集I<sub>0</sub>,因项目F→·(E)及F→·id属于I<sub>0</sub>,所以分别有 <br>
action[0,(]=shift 4 <br>
action[0,id]=shift 5 <br>
在I<sub>0</sub>中的其余项目都不生成动作。</p>
<p>考虑I<sub>1</sub>,因项目S'→ E·及E→E·+T均属于I<sub>1</sub>, 所以有 <br>
action[1,$]=accept <br>
action[1,+]=shift 6 <br>
</p>
<p>考虑I<sub>2</sub>={E→T·,T→T·*F}, 因FOLLOW(E)={$,+,)},所以集合I<sub>2</sub>中第一个项目使得 <br>
action[2,$] = action[2,+] =action[2,)]=reduce 2 </p>
<p>reduce 2表示用文法(4.16)的第二个产生式E→T进行归约。集合I<sub>2</sub>中第二个项目使得 <br>
action[2,*]=shift 7 </p>
<p>依此类推,可得到文法(4.16)的分析表,如表4.11所示。利用这张 分析表,假定输入符号串是id*id+id,LR分析器的工作过程,即二元式的变化过程如表4.12所示。</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.4b.htm'" width="24" height="24"></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.7.2.5b.htm'" width="26" height="24"></img></td>
</tr>
</table>
</BODY>
</html>
<html><script language="JavaScript">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -