📄 4.4.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.3.2.0c.htm'" width="24" height="24"></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.4b.htm'" width="26" height="24"></img></td>
</tr>
</table>
<br><br>
<font class="title2"><b>4.4 自顶向下的带回溯的分析方法简介 </b></font>
<table><tr><td>    </td>
<td class="content">
<p>并不是每个文法经改写后都可采用自顶向下的预测分析方法。例如文法G[S](4.11):
<table align=center width=450 class="content">
<tr><td>G[S](4.11),其产生式如下:</td><td></td></tr>
<tr><td>S→aSa|aa </td><td>(4.11)</td></tr>
</table>
这个文法产生偶数个a的所有串。这个文法进行提取左公因子后,也不比现在进步多少。面对输入串w,扫描程序从左至右读w,即使往后多看n个符号,一般来说也不知道选择哪个候选式能正确分析下去。不得已,只好采用试探法,不妨先选择最长的候选式进行推导,如不行,再选用另一个候选式。设w=aaaa$,分析过程如下:
</p>
</td></tr></table>
<p>
<center><img src="images/4.102.1.gif"></center><br><center>
<p></p>
</center></p>
<table><tr><td>    </td>
<td class="content">
<p>至此,发现分析选用的候选式不对,回退到第3步选用S→aa进行分析。</p>
</td></tr></table>
<br>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.3.2.0c.htm'" width="24" height="24"></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.4b.htm'" width="26" height="24"></img></td>
</tr>
</table>
</BODY>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -