📄 7.2.2c.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='7.2.2b.htm'" ></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'"
onclick="vbscript:window.location.href='7.2.3.htm'" ></td>
</tr>
</table>
<p><br>
<br>
<table>
<tr>
<td> </td><br><br>
<td class="content">
<p>在用产生式;
<center>
A→B C{action<sub>A</sub>}
</center>
归约时,所有关于非终结符号B,C的语义动作均已先于action<sub>A</sub>完成。 action<sub>A</sub> 表示A的语义动作。因此,在图7.6中将先做与标记非终结符号M相连的语义动作。
</p>
<p>M的语义动作把栈tblptr初始化为仅含一个指针,该指针指向由mktable(nil)创建的初始符号表,即最外层作用域的符号表;同时还把相对地址0压入栈offset中。标记非终结符号N,当出现一个过程说明时,也类似M作同样的工作。它的语义动作使用mktable(top(tblptr))来创建一个新的符号表。其中参数top(tblptr)为指向刚好包围此嵌人过程的外围过程符号表的指针。然后把调用该过程返回的指向新表的指针压人栈tblptr的栈顶,同时把相对地址0压入offset栈顶。
</p>
<p>每遇到一个变量说明<b>id</b>:T就在当前符号表中插入关于<b>id</b>的表项。这时栈tblptr保持不变,而栈offset的栈顶值增加T.width。当开始执行产生式D→<b>proc
id</b>;ND<sub>l</sub>;S右边的语义动作时,由D<sub>1</sub>产生的所有名字占用的总域宽便是offset的栈顶值,它由过程addwidth记录下来;同时,栈tblptr及offset的栈顶值被弹出,我们返回到上一层外围过程中的说明语句继续处理。并在此时在该外围过程的符号表中插入过程名字id的表项。
</td>
</tr>
</table>
<table>
<tr>
<td><font class="yanshi"> 观看演示 </font></td>
<td><font color="blue" onmouseover="javascript:style.cursor='hand'"
onclick="javascript:open('applets/test7_3/Page1.htm','_blank','menu=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,left=100,top=100,width=890,height=600')">处理嵌套过程中的说明语句</font></td>
<td><img src="../images/yanshi.gif" width="36" height="35"></td>
</tr>
</table>
<p><br>
</p>
<table align="right" width="300">
<tr>
<td><img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'"
onclick="vbscript:window.location.href='7.2.2b.htm'" ></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'"
onclick="vbscript:window.location.href='7.2.3.htm'" ></td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -