📄 4.6.1.0.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.6.0c.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.6.1.0b.htm'"></img></td>
</tr>
</table>
<br><br>
<font class="title2"><b>4.6.1 利用算符优先关系寻找右句型的可归约串</b></font>
<table><tr><td>    </td>
<td class="content">
<p>假设我们有算符文法的一个右句型。由算符文法的定义,我们知道没有相邻非终结符号出现在产生式的右部。因而右句型也没有相邻的非终结符号。于是我们可将右句型写成
<table align=center width=450 class="content">
<tr><td>β<sub>0</sub>a<sub>1</sub>β<sub>1</sub>a<sub>2</sub>β<sub>2</sub>…a<sub>n</sub>β<sub>n</sub></td></tr>
</table>
其中β<sub>i</sub>或是ε或是一个单个非终结符号,并且每一个a<sub>i</sub>是一个单个终结符号。假设在a<sub>i</sub>和a<sub>i+1</sub>之间恰好在三个关系<·,<img src="images/equalpoint.gif" width="20" height="19">,·>中有一个成立。进而我们用$作为每一个右句型符号串的左右分界符,且对任何终结符号a规定$<·a和a·>$。现在假定让我们从符号串
<table align=center width=450 class="content">
<tr><td>$β<sub>0</sub>a<sub>1</sub>β<sub>1</sub>a<sub>2</sub>β<sub>2</sub>…a<sub>n</sub>β<sub>n</sub>$</td></tr>
</table>
中移走非终结符号,并在剩下的符号串中的每一对相邻终结符号之间置放它们的优先关系<·,<img src="images/equalpoint.gif" width="20" height="19" >,或·>,得到一个新的符号串。例如,假定我们有文法(4.13)的一个右句型id+id*id,并且文法(4.13)与此例有关的一部分优先关系如表4.8所示。
<p>于是这个符号串(没有非终结符号)用优先关系插入后得到</p>
<p>$<·id ·> + <·id·>*<·id·>$ (4.14)</p>
<center><img src="images/table4.8.gif" width="311" height="229"></center>
<table align=left>
<td><font class="yanshi">    观看演示 </font></td>
<td>
<font color=blue onmouseover="javascript:style.cursor='hand';" onclick="javascript:open('applet/test4_5/Page1.htm','_blank','left=100,top=100,scrollbars=yes,resizable=yes,width=850,height=600')">算符优先分析法分析过程</font>
</td>
<td><img src="../images/yanshi.gif"></img></td>
</table>
<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.6.0c.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.6.1.0b.htm'"></img></td>
</tr>
</table>
</BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -