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

📄 4.6.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.6.0.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.6.0c.htm'"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>     
<td class="content">     

<p>由于文法(4.13)是一个二义文法,它的句子往往有不同的规范推导,因而就有不同的规范归约(归约过程中右句型的句柄可能不唯一)。但是,如果我们按传统的习惯规定:乘幂运算符的优先级高于乘、除运算符的优先级;乘除运算符的优先级高于加、减运算符的优先级;同级运算符服从左结合原则,即左边优先于右边;有括号时,先括号内后括号外。在这些规定下,文法的句子id+id-id*(id+id)的归约过程为: </p>
<p>(1)id+id-id*(id+id) <br>
&nbsp;&nbsp;&nbsp;&nbsp;(2)E+id-id*(id+id) <br>
&nbsp;&nbsp;&nbsp;&nbsp;(3)E+E-id*(id+id) <br>
&nbsp;&nbsp;&nbsp;&nbsp;(4)E-id*(id+id) <br>
&nbsp;&nbsp;&nbsp;&nbsp;(5)E-E*(id+id) <br>
&nbsp;&nbsp;&nbsp;&nbsp;(6)E-E*(E+id) <br>
&nbsp;&nbsp;&nbsp;&nbsp;(7)E-E*(E+E) <br>
&nbsp;&nbsp;&nbsp;&nbsp;(8)E-E*(E)<br>
&nbsp;&nbsp;&nbsp;&nbsp;(9)E-E*E<br>
&nbsp;&nbsp;&nbsp;&nbsp;(10)E-E<br>
&nbsp;&nbsp;&nbsp;&nbsp;(11)E</p>
<p>这个归约过程是唯一的。当从(3)归约到(4)时,相继的两个运算符“+”和“-”虽属同一优先级,但因采用左结合原则,故“+”优先于“-”(记为+·>一),因此,先把E+E归约为E 。当从(5)归约到(6)时,因“-”的优先级低于“*”(记为-<·*),所以,不能立即把E-E归约为E,而必须首先设法归约乘法运算。又因“*”的右操作数是带括号的,故必须先对括号里的式子进行归约。当从(8)归约到(9)时,同样不能先归约减法而必须先归约乘法,但由于乘法的右运算对象含有括号,因此,首先又必须把括号拿掉,这次归约同时去掉两个终结符号“(”与“)”,这两个终结符号的优先级认为是相同的(记为(<img src="images/equalpoint.gif" width="20" height="19">) )。 </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.6.0.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.6.0c.htm'"></img></td>
</tr>     
</table>     
     
</BODY>     
</html>

⌨️ 快捷键说明

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