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

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

<table>
<tr>
<td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>当使用产生式B→B<span class="down"><sub>1</sub></span> sub B<span class="down"><sub>2</sub></span>时,函数shrink使B<span class="down"><sub>2</sub></span>.ps减少30%。当用函数disp计算B.ht时,可以把B<span class="down"><sub>2</sub></span>的盒子向下放置。这里,产生实际排字命令的规则没有表示出来。 
</p>
</td>
</tr>
</table>

<table>
<tr>
<td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
表5.7中的语法制导定义是L-属性定义,唯一的继承属性是非终结符号B的ps属性。在所有的语义规则中,它仅由产生式左边非终结符号的继承属性来定义或是一个常数。因此这个语法制导定义是L-属性定义。
</p>
</td>
</tr>
</table>

<table>
<tr>
<td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; S→{B.ps:=10}<br> 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B{S.ht:=B.ht}<br> 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B→ {B<sub>1</sub>.ps:=B.ps}<br> 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B<sub>1</sub>  
{B<sub>2</sub>.ps:=B.ps}<br> 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B<sub>2</sub>{B.ht:=max(B<sub>1</sub>.ht,B<sub>2</sub>.ht)}<br> 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B→ {B<sub>1</sub>.ps:=B.ps}<br> 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B<sub>1</sub><br> 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sub  
{B<sub>2</sub>.ps:=shrink(B.ps)}<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B<sub>2</sub>{B.ht:=disp(B<sub>1</sub>.ht,B<sub>2</sub>.ht)}<br> 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B→text{B.ht:=text.h*B.ps} 
</p>
</td>
</tr>
</table>


<p align=center>图5.12 &nbsp&nbsp从表5.7构造的翻译模式</p> 

<table>
<tr>
<td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
图5.12中的翻译模式是通过在产生式中插入与表5.7中语义规则相应的语义动作得到的,当然还要满足上面所述的三个条件。为了可读性好,产生式中每个文法符号都写在不同的行上,右边表示的是动作。于是<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S→{B.ps:=10} 
B{S.ht:=B.ht}<br>
写成<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S→ {B.ps:=10}<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B&nbsp;{S.ht:=B.ht}<br>
注意,置继承属性B<span class="down"><sub>1</sub></span>.ps和B<span class="down"><sub>2</sub></span>.ps值的动作正好出现在产生式右边B<span class="down"><sub>1</sub></span>和B<span class="down"><sub>2</sub></span>的前面。
</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='5.4.2_2htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='5.5.0.htm'"></img></td>
</tr>
</table>

</BODY>

⌨️ 快捷键说明

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