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

📄 4.4b.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.4.htm'" width="24" height="24"></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.5.1.0.htm'" width="26" height="24"></img></td>
</tr>
</table>
<br><br>
<center><img src="images/4.102.2.gif" width="537" height="137"></center><br><center>
</center></p>  
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>        
<td class="content">   
<p>和输入串不匹配,回退到第2步,再选用S→aa产生式进行分析:</p> 
</td></tr></table>   
<p>     
<center><img src="images/4.102.3.gif" width="541" height="110"></center><br><center>
<p></p>
</center></p>  
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>        
<td class="content">   
<p>仍和输入串w不匹配。继续回退到第1步,再选用S→aa进行分析:</p> 
</td></tr></table>   
<p>     
<center><img src="images/4.102.4.gif" width="538" height="77"></center><br><center>
<p></p>
</center></p>  
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>        
<td class="content">   
<p>至此,为w=aaaa构造出了最左推导,证明w=aaaa是文法G[S](4.11)的句子。</p> 
<p>上述分析称为带回溯的自顶向下分析,它对于被分析的输入串,从文法的开始符号出发,反复使用不同的产生式谋求匹配输入串。当用某个非终结符号的候选式进行匹配失败时,删除这个失败分析建立的分析树分支并回头查输入符号,以便与其它候选式匹配。</p>    
<p>我们可以为每个非终结符号设计一个递归布尔函数过程完成这种回溯分析。在进入过程未分析前,要保存当前分析格局,包括输入符号串指针,使用规则指针,分析树结构等。一旦发现它的某个候选式与输入串匹配,就用这个候选式去扩展分析树,并返回“真”值;否则,恢复进入过程时保存的分析格局,并返回“假”值。</p>   
 
<p>另外,语义分析和转换一般采用语法制导翻译技术,那就会更麻烦,在保存和恢复现场格局方面,还要包括语义方面的工作,像符号表中的信息和生成代码,现场格局等。</p>     
<p>从上面的讨论可以看出,这种带回溯的自顶向下分析技术,效率很低,代价极高,因此,它只有理论上的意义,而在实践中价值不大,没有人会用它构造语法分析器。因此,它的实现技术在教程中也不作详细介绍。</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.4.htm'" width="24" height="24"></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.5.1.0.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 + -