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

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

<p><br>
<br>

<table>
  <tr>
    <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
    <td class="content">在翻译if-then语句S→<b>if</b> E <b>then</b> S<span class="down">1</span>时,我们建立了一个新的标号E.true,并且用它来标识关于S<span
    class="down">1</span>的代码的第一条指令,如图7.13(a)所示。表7.4给出了一个语法制导定义。在E的代码中将有这样的转移指令:若E为真则转移到E.true,并且若E为假则转移到S.next因此我们置E.false为S.next. 
    <p align="center"><br>
    表7.4 &nbsp;控制流语句的语法制导定义<br>
    </p>
    <table width="85%" align="center" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td width="40%" height="30" align="center">产生式</td>
        <td width="60%" align="center">语义规则</td>
      </tr>
      <tr>
        <td align="left" valign="top"><br>
        <p>S -&gt;<b>if</b> E <b>then</b> S<sub>1</sub></p>
        <p><br>
        <br>
        <br>
        <br>
        <br>
        </p>
        <p>S -&gt;<b>if</b> E <b>then</b> S<sub>1</sub><br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>else</b> S<sub>2</sub></p>
        <p><br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        </p>
        <p>S -&gt;<b>while</b> E <b>do</b> S<sub>1</sub></td>
        <td align="left" valign="top"><br>
        &nbsp;&nbsp;&nbsp;&nbsp;E.true := newlabel;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;E.false := S.next;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;S<sub>1</sub>.next := S.next<br>
        &nbsp;&nbsp;&nbsp;&nbsp;S.code := E.code ||<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gen(E.true ':') || S<sub>1</sub>.code<br>
        &nbsp;&nbsp;&nbsp;<br>
        &nbsp;&nbsp; &nbsp;E.true := newlabel;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;E.false := newlabel;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;S<sub>1</sub>.next := S.next<br>
        &nbsp;&nbsp;&nbsp;&nbsp;S<sub>2</sub>.next := S.next;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;S.code := E.code ||<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gen(E.true ':') || S<sub>1</sub>.code 
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ||gen('goto' S.next) ||<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gen(E.false ':') || S<sub>2</sub>.code 
        &nbsp;<br>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;S.begin := newlabel;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;E.true := newlabel;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;E.false := S.next<br>
        &nbsp;&nbsp;&nbsp;&nbsp;S<sub>1</sub>.next := S.begin<br>
        &nbsp;&nbsp;&nbsp;&nbsp;S.code := gen(S.begin ':') <br> 
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|| E.code ||gen(S.true ':') <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|| S<sub>1</sub>.code <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;||gen('goto' S.begin) <br>
        </td>
      </tr>
    </table>
    </td>
  </tr>
</table>


<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.4.3.htm'" width="24" height="24" ></td>
    <td>
    <img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'"
    onclick="vbscript:window.location.href='7.4.3c.htm'" width="26" height="24" ></td>
  </tr>
</table>
</body>
</html>
<html><script language="JavaScript">

⌨️ 快捷键说明

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