📄 5.7.0_3b.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_3.htm'" ></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='5.8.0.htm'"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>    </td>
<td class="content">
<P>
计算表5.12中综合属性值的函数如图5.28所示。在此例中我们对每个非终结符号的每个综合属性都使用了不同的函数。
</p>
</td></tr></table>
<table><tr><td></td>
<td class="content">
<P>
<b> <font color="#0000FF">function</font></b> Es(n);
<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>
'E→E<sub>1</sub>E<sub>2</sub>':
<br>
s1:=Es(child(n,1));
<br>
s2:=Es(child(n,2));
<br>
<b> <font color="#0000FF">return</font></b>
fs(s1,s2); <br>
'E→id':
<br>
<b> <font color="#0000FF">return</font>
id</b>.s; <br>
<b> <font color="#0000FF">default</font></b>:
<br>
error;
<br>
<b> <font color="#0000FF">end</font>
</b><br>
<b> <font color="#0000FF">end</font></b>; <br>
<b> <font color="#0000FF">function</font></b> Et(n,i);
<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>
'E→E<sub>1</sub>E<sub>2</sub>':
<br>
i1:=fi1(i);:
<br>
t1:=Et(child(n,1),i1);
<br>
i2:=fi2(i);
<br>
t2:=Et(child(n,2),bnmi2);
<br>
<b><font color="#0000FF">return</font></b>
ft(t1,t2); <br>
'E→<b>id</b>':
<br>
<b> <font color="#0000FF">return</font></b>
h(i); <br>
<b> <font color="#0000FF">detault</font></b>:
<br>
error
<br>
<b> <font color="#0000FF">end</font>
<br>
<font color="#0000FF">end</font></b>; <br>
<b> <font color="#0000FF">function</font></b> Sr(n);
<br>
<b> <font color="#0000FF">begin</font></b> <br>
s:=Es(child(n,1));
<br>
i:=g(s);
<br>
t:=Et(child(n,1),i);
<br>
<b> <font color="#0000FF">return</font></b>
t <br>
<b> <font color="#0000FF">end</font></b>;<br>
<br>
<b>图5.28 </b>
计算表5.12中综合属性值的函数<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_3.htm'" ></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='5.8.0.htm'"></img></td>
</tr>
</table>
</BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -