📄 5.6.3_1.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.6.3b.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='5.6.3_1b.htm'"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>    </td>
<td class="content">
<P>
<b>例5.19</b> 表5.10中使用了三个标记非终结符号L,M和N,以使得当B的子树被归约时,继承属性B.ps的值在分析栈中的位置是可知的。原来的语法制导定义在表5.7中给出,与其相应的说明在例5.13中已经解释了。
</p>
</td></tr></table>
<br><br>
<center>表5.10  所有继承属性都由复写规则赋值</center>
<table width="75%" align=center valign=top border=1 cellspacing=0 cellpadding=5>
<tr>
<td width="42%" height=30 align=center>产生式</td>
<td width="58%" align=center>语义规则</td>
</tr>
<tr>
<td align=left valign=top>
<br>
<p>S -> L B<br></p>
<br>
<p>L -> ε</p>
<p>B -> B<sub>1</sub> M B<sub>2</sub><br></p>
<br><br><br>
<p>B -> B<sub>1</sub> sub N B<sub>2</sub></p>
<br><br><br><br>
<p>B -> <b>text</b></p>
<p>M -> ε</p>
<p>N -> ε</p>
<br>
</td>
<td align=leftj valigh=top>
<br>
<p>  B.ps := L.s<br>
      S.ht := B.ht</p>
<p>  L.s := 10</p>
<p>  B<sub>1</sub>.ps := B.ps<br>
      M.i := B.ps<br>
      B<sub>2</sub>.ps := M.s<br>
      B.ht := max(B<sub>1</sub>.ht,B<sub>2</sub>.ht)</p>
<p>  B<sub>1</sub>.ps := B.ps<br>
      N.i := B.ps<br>
      B<sub>2</sub>.ps := N.s<br>
      B.ht := disp(B<sub>1</sub>.ht,B<sub>2</sub>.ht)</p>
<p>  B.ht := <b>text</b>.h×B.ps</p>
<p>  M.s := M.i</p>
<p>  N.s := shrink(N.i)</p>
<br>
</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.6.3b.htm'"></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='5.6.3_1b.htm'"></img></td>
</tr>
</table>
</BODY>
<html><script language="JavaScript">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -