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

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

<font class="title2"><b>练习</b></font>
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">

<a name="5.18"></a>

<hr size=2 align=center color=red><br>               

5.18 文法G[P]及其产生式如下: <br>                                          
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;P→D;E <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;D→D;D|<b>id</b>:T <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T→list of T|<b>char</b>|<b>integer</b>                                           
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;E→(L)|Literal|<b>num</b>|<b>id</b> 
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;L→E,L|E <br>
        &nbsp;&nbsp;&nbsp;&nbsp;这个文法产生由字面常量组成的表。符号的解释和文法(5.10)相同,增加类型List,它表示类型为T的元素构成的表。写一个类似5.8.2中图5.33的翻译模式,以确定表达式(E)和(L)的类型(注:表中每个元素的类型是一样的)。 
<table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('key/a_5.18.htm','','left=50,top=40,toolbar=no,scrollbars=yes,width=600,height=600')"></img>
</td></tr>
</table>
<a name=5.19></a>
<hr size=2 align=center color=red><br>               

5.19 修改图5.34的翻译方案,使之能够处理: <br>                                          
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a)语句有值。赋值语句的值是赋值号右边的表达式的值。条件语句或当语句的值是语句体的值,语句表的值是表中最后一个语句的值。 
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b)布尔表达式。加上逻辑算符and,or和not,还有关系算符的产生式,然后给出适当的翻译规则,计算出这些表达式的类型。 
<table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('key/a_5.19.htm','','left=50,top=40,toolbar=no,scrollbars=yes,width=600,height=600')"></img>
</td></tr>
</table>
<a name=5.20></a>
<hr size=2 align=center color=red><br>               

5.20 假定类型名link和cell如(5.9)中的定义,下面哪些表达式结构等价?哪些名字等价?<br>
&nbsp;&nbsp;&nbsp;&nbsp;(1)Link&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;(2)pointer(cell)&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;(3)pointer(Link)&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;(4)pointer(record(info×integer)×(next×pointer(cell)))                                           
<table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('key/a_5.20.htm','','left=50,top=40,toolbar=no,scrollbars=yes,width=600,height=450')"></img>
</td></tr>
</table>
<hr size=2 align=center color=red><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.2_3.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='../c_6/6.0.htm'"></img></td>
</tr>
</table>

</BODY>

<html><script language="JavaScript">

⌨️ 快捷键说明

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