⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 4.7.2.5.htm

📁 建立《编译原理网络课程》的目的不仅使学生掌握构造编译程序的原理和技术
💻 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>&nbsp&nbsp&nbsp&nbsp</td> 
<td class="content">  
<p>现在让我们根据算法4.9来构造文法(4.16)的SLR分析表。考虑项目集I<sub>0</sub>,因项目F→·(E)及F→·id属于I<sub>0</sub>,所以分别有 <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action[0,(]=shift 4 <br>   
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action[0,id]=shift 5 <br>   
&nbsp;&nbsp;&nbsp;&nbsp;在I<sub>0</sub>中的其余项目都不生成动作。</p>   
<p>考虑I<sub>1</sub>,因项目S'→ E·及E→E·+T均属于I<sub>1</sub>, 所以有 <br>   
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action[1,$]=accept <br>   
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action[1,+]=shift 6 <br>   
</p>   
<p>考虑I<sub>2</sub>={E→T·,T→T·*F}, 因FOLLOW(E)={$,+,)},所以集合I<sub>2</sub>中第一个项目使得 <br>   
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action[2,$] = action[2,+] =action[2,)]=reduce 2 </p>   
<p>reduce 2表示用文法(4.16)的第二个产生式E→T进行归约。集合I<sub>2</sub>中第二个项目使得 <br>   
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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 + -