📄 4.10.0.2.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='4.10.0.1b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.10.0.2b.htm'"></img></td>
</tr>
</table>
<br><br>
<font class="title2"><b>练习</b></font>
<table><tr><td> </td>
<td class="content">
<a name="4.16"></a>
4.16 考虑文法G[S],其产生式如下<br>
S→AS | b <br>
A→SA | a<br>
(1)构造文法G[S]的LR(0)项目集规范族及相应的DFA。<br>
(2)如果把每一个LR(0)项目看成一个状态,并从每一个形如B→α·Xβ的状态出发画一条标识为X的箭弧到状态B→αX·β,而且从每一个形如B→α·Aβ的状态出发画标记为ε的箭弧到所有形如A→·γ的状态。这样就得到了一个NFA。说明这个NFA与(a)的DFA是等价的。<br>
(3)构造文法的SLR分析表。<br>
(4)对于输入串bab,给出SLR分析器所作出的动作。<br>
(5)构造文法的LR(1)分析表和LALR分析表。<br>
<table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('4.10.16.htm','','left=100,top=100,scrollbars=yes,resizable=yes,toolbar=no,width=610,height=500,scrolling=yes')"></img>
</td></tr>
</table>
<a name="4.17"></a>
<hr size=2 align=center color=red><br>
4.17 证明下面文法是LL(1)的但不是SLR(1)文法<br>
S→AaAb|BbBa <br>
A→ε <br>
B→ε <br>
<table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('4.10.17.htm','','left=100,top=100,scrollbars=yes,resizable=yes,toolbar=no,width=500,height=500,scrolling=yes')"></img>
</td></tr>
</table>
<a name="4.18"></a>
<hr size=2 align=center color=red><br>
4.18 证明任何SLR(1)文法都是LR(1)文法<br>
<table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('4.10.18.htm','','left=100,top=100,scrollbars=yes,resizable=yes,toolbar=no,width=610,height=500,scrolling=yes')"></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='4.10.0.1b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.10.0.2b.htm'"></img></td>
</tr>
</table>
</BODY>
</html>
<html><script language="JavaScript">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -