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

📄 4.3.2.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.3.2.0.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.3.2.0c.htm'"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>  
<td class="content">   
<p><font class="example">例4.10  </font>下面的文法是“未定的else"文法的简写形式。</p>
<table align=center width=450 class="content"> 
<tr><td>S→iEtS|iEtSeS|a</td><td></td></tr> 
<tr><td>E→b</td><td> (4.8)</td></tr>      
</table> 
<p>其中,i,t,e分别表示if,then和else,E和S分别表示表达式和语句。提取了公共左因子之后,文法变为文法(4.5)。于是,对于输入i,我们可以展开S为iEtSS',直到iEtS分析完毕再去决定把S'展为eS或ε。自然,文法(4.8)和(4.5)都是二义的,有关详细情况已在例4.7中进行过讨论。</p>
<p><font class="example">例4.11  </font>若有文法G[S](4.9),其产生式如下: </p>
<table align=center width=450 class="content"> 
<tr><td>S→aSd|Ac </td><td></td></tr> 
<tr><td>A→aS|b </td><td> (4.9)</td></tr>      
</table> 
<p>把A的产生式代入S的产生式中,S的产生式变为: </p>
<table align=center width=450 class="content"> 
<tr><td>S→aSd|aSc|bc</td></tr>    
</table> 
<p>提取公共左因子: </p>
<table align=center width=450 class="content"> 
<tr><td>S→aSS'|bc</td></tr> 
<tr><td>S'→d|c</td></tr>      
</table> 
<p>显然,原文法中的非终结符号A变成不可到达的符号,因此,关于A的产生式也就成为无用产生式,应予以删除。 </p>
<p>不一定每个文法的左公共因子都能在有限步骤内替换成无左公共因子的文法,在此请读者对文法G[S](4.10)进行提取公共左因子的变换,看会出现什么情形。</p>
&nbsp;&nbsp;&nbsp;&nbsp;G[S](4.10), 其产生式如下:
<table align=center width=450 class="content"> 
<tr><td>S→Ap|Bq</td><td></td></tr> 
<tr><td>A→aAp|d</td><td>(4.10)</td></tr>
<tr><td>B→aBq|e</td><td></td></tr>
</table>
</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.3.2.0.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.3.2.0c.htm'"></img></td>
</tr>     
</table>     
     
</BODY>     
</html>
<html><script language="JavaScript">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -