📄 5.4.0.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.3.1b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='5.4.1.htm'"></img></td>
</tr>
</table>
<br><br>
<font class="title2"><b>5.4 L-属性定义</b></font>
<table>
<tr>
<td>    </td>
<td class="content">
<p>
当在分析过程中同时进行翻译时,属性的计算顺序是与用分析方法建立分析树结点的顺序相联系的,一种描述自顶向下和自底向上多种翻译方法中的属性计算的自然顺序是深度优先顺序。它可由图5.9所示的过程dfvisit得到,只要当调用过程dfvisit时,以分析树的根结点作为实在参数即可。
</p>
</td>
</tr>
</table>
<table><tr><td>    </td>
<td class="content">
<b> <font color="#0000FF">procedure</font></b>
dfvisit(n:node);<br>
<b> <font color="#0000FF">begin</font></b><br>
<b> <font color="#0000FF">for</font></b>
n 的每一个子结点m,从左至右<b><font color="#0000FF">do begin</font></b><br>
计算m的继承属性;<br>
dfvisit(m)<br>
<b> <font color="#0000FF">end</font></b>;<br>
计算n的综合属性<br>
<b> <font color="#0000FF">end</font></b>
</td></tr></table>
<p align=center>图5.9计算栈中属性的深度优先的顺序</p>
<table><tr><td>    </td>
<td class="content">
<p>
现在我们介绍一类语法制导定义,它叫作L-属性定义,它的属性都可以用深度优先的顺序计算(L表示“left”,因为属性信息是从左到右相继出现的)。这一章下面三节中将讨论L-属性定义的实现。L-属性定义包含了所有基于LL(l)文法的语法制导定义;在第5.5节中将给出一种实现这类定义的预测分析方法。第5.6节将介绍通过扩充5.3节中的翻译方法在自底向上的分析过程中实现L-属性定义的方法。实现所有L-属性定义的一般方法将在5.7节中作简要介绍。
</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.3.1b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='5.4.1.htm'"></img></td>
</tr>
</table>
</BODY>
<html><script language="JavaScript">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -