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

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

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>
<b>例5.23</b>  设有Pascal 程序片段:  
</p>
</td></tr></table>
    

<table><tr><td>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>
<b>&nbsp;&nbsp;<font color="#0000FF">TYPE</font> </b><br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;stype=<b><font color="#0000FF">RECORD</font> </b><br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name:<b><font color="#0000FF">ARRAY</font></b> [1..8] OF char; <br> 
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;score:integer  
        <br>
        &nbsp;&nbsp;&nbsp; <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000FF">END</font></b>; 
        <br>
        &nbsp;&nbsp;&nbsp;<b>&nbsp;&nbsp;&nbsp;<font color="#0000FF">VAR</font> </b><br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;table:<b><font color="#0000FF">ARRAY</font></b> [1..50]  
        OF stype; <br> 
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;p: ↑stype;  
</p>
</td></tr></table>
    
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>
则stype代表的类型表达式 
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>
<b>&nbsp;&nbsp;<font color="#0000FF">RECORD</font></b>((nameX<b><font color="#0000FF">ARRAY</font></b>(1..8,char))X(scoreXinteger)) 
</p>
</td></tr></table>

<table width="470"><tr><td width="16">&nbsp&nbsp&nbsp&nbsp</td>
<td class="content" width="440">
<P>
和table绑定的类型表达式 &nbsp; <font color="#0000FF">ARRAY</font>(1..50,stype) 
</p>
</td></tr></table>

<table width="468"><tr><td width="16">&nbsp&nbsp&nbsp&nbsp</td>
<td class="content" width="438">
<P>
和P绑定的类型表达式  &nbsp;&nbsp; <font color="#0000FF">POINTER</font>(stype) 
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>
<b>例5.24</b>  设有下面的函数定义  
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>
&nbsp;&nbsp;&nbsp;<b><font color="#0000FF">FUNCTION</font></b> f(P1:T1;P2:T2;…,Pn:Tn):T;  
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#0000FF">BEGIN</font></b> ……<b><font color="#0000FF">END</font></b>; 
<br>
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>和f绑定的类型表达式 &nbsp;&nbsp; T<sub>1</sub>XT<sub>2</sub>X…XT<sub>n</sub>→T  
</p>
</td></tr></table>


<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>
具体说来,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#0000FF">FUNCTION</font></b>  
f(a,b:<font color="#0000FF">char</font>):↑<font color="#0000FF">integer</font>; 
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color="#0000FF">BEGIN</font></b> …<b><font color="#0000FF">END</font></b>; 
<br>&nbsp;&nbsp;&nbsp;&nbsp;和f绑定的类型表达式为 
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char X char→POINTER(integer) 
 </p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>
<b>例5.25</b>  在函数式语言中可如下定义恒等函数 
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>
&nbsp;&nbsp;&nbsp;&nbsp;fun f(x)=x  &nbsp;&nbsp; x可以是任何类型的语言结构。
</p>
</td></tr></table>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>
因此x可以是任何类型f的类型表达式为 
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;α→α&nbsp;&nbsp;  α为类型变量,其值是任何类型表达式。 
<p>
</p>
</td></tr></table>


<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<P>
多态类型语言结构的类型表达式中含类型变量,这种语言的类型分析和类型检查应在专门论题中讨论。 
</p>
</td></tr></table>

<br>
<hr size=2 color=red width=90%>
<br>

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

</BODY>

⌨️ 快捷键说明

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