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

📄 6.4.0c.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='6.4.0b.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='6.4.2.htm'"></img></td>
</tr>
</table>
<br><br>


<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
在图6.15中所设计的C语言程序的每一个说明把被说明的名字初始化为该说明所在的块的序号。在B<sub>0</sub>中的b的说明的作用域不包括B<sub>1</sub>,因为b在B<sub>1</sub>中重新被说明,在图中用B<sub>0</sub>-B<sub>1</sub>来表示。这样的一个间隙称作是在说明的作用域中的一个洞(hole)。  
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
最近嵌套作用域规则将反映在图6.15的程序的输出中。控制恰好自块的源程序正文开始之前的一点处流入,并且恰好流出到块的源程序正文结束之后的一个位置,于是打印语句执行的顺序是B<sub>2</sub>,B<sub>3</sub>,B<sub>1</sub>和B<sub>0</sub>,即控制离开块的顺序。在这些块中的a和b之值是: 
<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
      &nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;   
        &nbsp;1 <br> 
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
      &nbsp;&nbsp;0   
        &nbsp;&nbsp;&nbsp; 3 <br>  
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0   
        &nbsp;&nbsp;&nbsp; 1 <br>  
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
      &nbsp;&nbsp;&nbsp;0   
        &nbsp;&nbsp;&nbsp; 0 <br>  
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
块结构可以用栈式存储分配实现。由于说明的作用域不会超出它所在的块,在进入块时可以为被说明的名字分配空间,并当控制离开该块时释放空间。对于图6.15中的块B<sub>0</sub>,我们可以如图6.16所显示的那样进行分配。局部名字a和b的角标标明它是在哪个块中被说明的。注意a<sub>2</sub> 和b<sub>3</sub>可能分配在同一空间中,因为它们所在的块不在同一时刻存活。  
</p>
</td></tr></table>

<table><tr>
<br>
<table width="15%" align=center border=1 cellspacing=0 cellpadding=5>
<tr>
<td align=center>a<sub>0</sub></td>
</tr>
<tr>
<td align=center>b<sub>0</sub></td>
</tr>
<tr>
<td align=center>b<sub>1</sub></td>
</tr>
<tr>
<td align=center>a<sub>2</sub>,b<sub>3</sub></td>
</tr>
</table>
<p><center><b>图6.16</b> &nbsp在图6.15中说明的名字的存储</center></p> 
 
<br>
<table align=right width=300>
<tr>
<td><img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='6.4.0b.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='6.4.2.htm'"></img></td>
</tr>
</table>

</BODY>

<html><script language="JavaScript">

⌨️ 快捷键说明

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