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

📄 4.5.1.0b.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.5.1.0.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.1.htm'" width="26" height="24"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>   
<td class="content">    
 
<font class="example">例4.12 </font>考虑文法G[S](4.12),其产生式如下:<br> 
<table align=center width=450 class="content">  
<tr><td>①S→aABe</td><td></td></tr>     
<tr><td>②A→b</td><td>(4.12)</td></tr> 
<tr><td>③A→Abc</td><td></td></tr> 
<tr><td>④B→d</td><td></td></tr> 
</table>     
<p>对于输入串abbcde,语法分析器从左至右每次读入一个符号,寻找能和产生式右部匹配的最左子串。在abbcde中b和d都是,选择最左的b,用A代替,得到aAbcde(相当于aAbcde<img src="images/equalr.gif" width="20" height="19">abbcde)。下一步,子串Abc,b,d都是产生式右部,选择Abc,用A代替之,得到aAde(相当于aAde<img src="images/equalr.gif" width="20" height="19">aAbcde)。然后,用B代替aAde中的d,得到aABe(相当于aABe<img src="images/equalr.gif" width="20" height="19">aAde)。最后把aABe归约到文法开始符号S(相当于S<img <img src="images/equalr.gif" width="20" height="19">aABe)。由此,我们得到下面的归约序列 
<table align=center width=450 class="content">  
<tr><td>abbcde aAbcde aAde aABe S</td></tr>     
</table>    
<p>它恰是S<img src="images/equalplus.gif" width="20" height="19">abbcde的最右推导的逆过程:</p>  
<table align=center width=450 class="content">  
<tr><td>S<img src="images/equalr.gif" width="20" height="19">aABe<img src="images/equalr.gif" width="20" height="19">aAde<img src="images/equalr.gif" width="20" height="19">aAbcde<img src="images/equalr.gif" width="20" height="19">abbcde</td></tr>     
</table>    
<p>图4.11从构造分析树的过程图示了上述归约过程,(a),(b),(c),(d)分别对应最右推导的④,③,②,①。它是从树叶开始,找出最左边一棵子树的子结点,然后找出其父结点,将其构造成(归约成)一棵子树。这种画树过程是从树叶画向树根,因此称作自底向上分析。</p> 
</td></tr></table>   
<p>     
<center><img src="images/4.11.gif" ></center><br> 
<center class="content">图4.11 对句子abbcde归约构造分析树的过程</center></p>  
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>        
<td class="content">    
<p>从上面的归约过程可以看出,在被归约句型中找出最左边的某个产生式的右部的子串是非常重要的,这个子串就是定义2.5中定义的句柄。下面,从归约过程更深入讨论句柄这个概念。</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.5.1.0.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.1.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 + -