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

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

<font class="title2"><b>7.1.2 三地址代码</b></font> 

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
三地址代码是由一般形式为
</p>
</td></tr></table>

<table><tr><td width=200>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
x:=y op z 
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
所表示的语句组成的序列。其中x,y,z为名字、常数或编译时产生的临时变量,op代表运算符号如定点算符、浮点算符、逻辑算符等等。例如,源语言表达式x+y*z可以被翻译为如下序列:
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
t<SPAN class=down><sub>1</sub></SPAN>:= y * z 
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
t<SPAN class=down><sub>2</sub></SPAN>:= x+t<SPAN class=down><sub>1</sub>
</p>
</span>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
其中t<SPAN class=down><sub>1</sub></SPAN>,t<SPAN class=down><sub>2</sub></SPAN>为编译时产生的临时变量。
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
三地址代码是语法树或dag的一种线性表示。例如图7.3给出了图7.1中的语法树和dag分别对应的三地址代码。三地址代码的含义在于每条语句通常包含三个地址,两个用来存放运算对象,一个用来存放结果。在以下给出的三地址代码中,对于用户定义的名字在实际实现时将由指向符号表中相应名字表项的指针所代替。
</p>
</td></tr></table>
<center>
<table align=center >
<tr><td width=250>t<SPAN class=down><sub>1</sub></SPAN>:=-c</td><td>t<SPAN class=down><sub>1</sub></SPAN>:=-c</td></tr>   
<tr><td>t<SPAN class=down><sub>2</sub></SPAN>:=b * t<SPAN class=down><sub>1</sub></SPAN></td><td>t<SPAN class=down><sub>2</sub></SPAN>:=b*t<SPAN class=down><sub>1</sub></SPAN></td></tr>   
<tr><td>t<SPAN class=down><sub>3</sub></SPAN>:=-c</td><td>t<SPAN class=down><sub>5</sub></SPAN>:=t<SPAN class=down><sub>2</sub></SPAN>+t<SPAN class=down><sub>2</sub></SPAN></td></tr>   
<tr><td>t<SPAN class=down><sub>4</sub></SPAN>:= b * t<SPAN class=down><sub>3</sub></SPAN></td><td>a := t<SPAN class=down><sub>5</sub></SPAN></td></tr>   
<tr><td>t<SPAN class=down><sub>5</sub></SPAN>:=t<SPAN class=down><sub>2</sub></SPAN>+t<SPAN class=down><sub>4</sub></SPAN></td><td></td></tr>   
<tr><td>a :=t<SPAN class=down><sub>5</sub></SPAN></td><td></td></tr>   
<tr><td>(a)对于语法树的代码</td><td>(b)对于dag的代码 </td></tr>
</table>


<table><tr>
<td class="content">
<b><br>图7.3 相应于图7.1的树和dag的三地址代码</b>
</td></tr></table>
</center>
<br>
<table align=right width=300>
<tr>
<td><img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='7.1.1c.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='7.1.3.htm'"></img></td>
</tr>
</table>


<html><script language="JavaScript">

⌨️ 快捷键说明

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