📄 5.7.0_2b.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.7.0_2.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='5.7.0_3.htm'"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>    </td>
<td class="content">
<P>
图5.25表示的是非终结符号A的函数;我们假设L,M,Q和R的函数也可被建立。图5.25中的变量是由非终结符号和它的属性来命名的;例如,变量li和ls对应于L.i和L.s。
</p>
</td></tr></table>
<table><tr><td>    </td>
<td class="content">
<P>
与产生式A→LM对应的代码的建立如同例5.20。也就是说,我们首先决定L的继承属性,然后再调用L的函数决定L的综合属性。对M的处理也一样。与L→QR相应的代码段首先访问R的子树,然后访问Q的子树。在其它方面,两个产生式的代码段是非常相似的。
</p>
</td></tr></table>
<table><tr><td></td>
<td class="content">
<P>
<b> <font color="#0000FF">function</font></b> A(n,ai);
<br>
<b> <font color="#0000FF">begin</font> </b><br>
<b> <font color="#0000FF">case</font></b>
在结点n的产生式 <b><font color="#0000FF">of</font></b> <br>
'A→LM':<font color="#008000">/*自左至右的顺序*/</font>
<br>
li:=l(ai);
<br>
ls:=L(child(n,1),li);
<br>
mi:=m(ls);
<br>
ms:=M(child(n,2),mi)
<br>
<b> <font color="#0000FF">return</font></b>
f(ms); <br>
'A→QR'
:<font color="#008000">/*自右至左的顺序*/</font> <br>
ri:=r(ai);
<br>
rs:=R(child(n,2),ri);
<br>
qi:=q(rs);
<br>
qs:=Q(child(n,l),qi);
<br>
<b> <font color="#0000FF">return</font></b>
f(qs); <br>
<b> <font color="#0000FF">default</font></b>:
<br>
error
<br>
<b> <font color="#0000FF">end</font></b>
<font color="#0000FF">
<br>
<b> end</b></font>; <br>
<br>
<b>图5.25</b>
图5.24中的依赖关系决定了子结点的被访问的顺序<br>
</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.7.0_2.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='5.7.0_3.htm'"></img></td>
</tr>
</table>
</BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -