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

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

<p><br>
<br>

<table>
  <tr>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
    <td class="content">&nbsp;&nbsp;&nbsp; 
    通过一遍扫描得到目标代码的布尔表达式的翻译模式如图7.14所示。在翻译模式中用到如下三个函数:<br>
    &nbsp;&nbsp;&nbsp; 1.makelist(i),它将创建一个仅包含i的新表,i 
    是四元式数组的一个索引(下标),或说i是四元式代码序列的一个标号。<br>
    &nbsp;&nbsp;&nbsp; 2.merge(p<span class="down"><sub>1</sub></span>,p<span class="down"><sub>2</sub></span>),它将连接由指针p<span
    class="down">1</span>和p2指向的两个表并且返回一个指向连接后的表的指针。<br>
    &nbsp;&nbsp;&nbsp; 3.backpatch(p,i),它将把i作为目标标号回填到p所指向的表中的每一个转移指令中去。<br>
<!--
        &nbsp;&nbsp;&nbsp; <img src="images/7_14.jpg" width="600" height="625"><br>
-->    </td>
  </tr>
</table>

<table align="center" border="0" cellPadding="10" cellSpacing="0" width="90%">
<TBODY>
  <tr>
    <td vAlign="top" width="41%">&nbsp;&nbsp;&nbsp; (1) E -&gt; E<span class="down"><sub>1</sub></span> 
    <b>or</b> M E<span class="down"><sub>2</sub></span><p><br>
    <br>
    <br>
    <br>
    </p>
    <p>(2) E -&gt; E<span class="down"><sub>1</sub></span> <b>and</b> M E<span class="down"><sub>2</sub></span></p>
    <p><br>
    <br>
    <br>
    </p>
    <p>(3) E -&gt; <b>not</b> E<span class="down"><sub>1</sub></span></p>
    <p><br>
    <br>
    </p>
    <p>(4) E -&gt; (E<span class="down"><sub>1</sub></span>)</p>
    <p><br>
    </p>
    <p>(5) E -&gt; <b>id</b><span class="down"><sub>1</sub></span><br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       &nbsp;&nbsp;<b>relop&nbsp;id</b><span
    class="down"><sub>2</sub></span></p>
    <p><br>
    <br>
    <br>
    <br>
    </p>
    <p>(6) E -&gt; <b>true</b></p>
    <p><br>
    </p>
    <p>(7) E -&gt; <b>false</b></p>
    <p><br>
    </p>
    <p>(8) E -&gt; ε</td>
    <td vAlign="top" width="59%">{ backpatch(E<span class="down"><sub>1</sub></span>.falselist,M.quad);<br>
    &nbsp;E.truelist := merge(E<span class="down"><sub>1</sub></span>.truelist,E<span
    class="down"><sub>2</sub></span>.truelist);<br>
    &nbsp;E.falselist := E<span class="down"><sub>2</sub></span>.falselist }<br>
    <br>
    { backpatch(E<span class="down"><sub>1</sub></span>.truelist,M.quad);<br>
    &nbsp;E.truelist := E<span class="down"><sub>2</sub></span>.truelist;<br>
    &nbsp;E.falselist := merge(E<span class="down"><sub>1</sub></span>.falselist,E<span
    class="down"><sub>2</sub></span>.falselist) }<br>
    <br>
    { E.truelist := E<span class="down"><sub>1</sub></span>.falselist;<br>
    &nbsp;E.falselist := E<span class="down"><sub>1</sub></span>.truelist }<br>
    <br>
    { E.truelist := E<span class="down"><sub>1</sub></span>.truelist;<br>
    &nbsp;E.falselist := E<span class="down"><sub>1</sub></span>.falselist }<br>
    <br>
    { E.truelist := makelist(nextquad);<br>
    &nbsp;E.falselist<br>
     &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; 
     := makelist(nextquad + 1);<br>
    &nbsp;emit('if' <b>id</b><span class="down"><sub>1</sub></span>.place <b>relop.</b>op <b>id</b><span
    class="down"><sub>2</sub></span>.place 'goto --')<br>
    &nbsp;emit('goto --') }<br>
    <br>
    { E.truelist := makelist(nextquad);<br>
    &nbsp;emit('goto --') }<br>
    <br>
    { E.falselist := makelist(nextquad);<br>
    &nbsp;emit('goto --') }<br>
    <br>
    { M.quad := nextquad }</td>
  </tr>
</TBODY>
</table>

<p align="center"><br>
图7.14 &nbsp;使用一遍扫描的布尔表达式的翻译模式 </p>
<p><br>
</p>

<table align="right" width="300">
  <tr>
    <td><img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'"
    onclick="vbscript:window.location.href='7.6.1.htm'" ></td>
    <td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'"
    onclick="vbscript:window.location.href='7.6.1c.htm'" ></td>
  </tr>
</table>
</body>
</html>

<html><script language="JavaScript">

⌨️ 快捷键说明

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