📄 4.9.2.1.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.9.2.0b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.9.2.1b.htm'"></img></td>
</tr>
</table>
<br><br>
<table><tr><td> </td>
<td class="content">
<p>除非有其它指示,否则Yacc按下面两条规则解决分析动作的冲突:</p>
<p>1.归约-归约冲突的解决是从冲突产生式中选择在Yacc说明中最先出现的那个产生式。
</p>
<p>2.移进-归约冲突的解决是优先选择移进。这条规则正确地解决了悬空else二义的移进-归约冲突。</p>
<p>因为这些缺省的规则并不总是编译器编写者所需要的,因而Yacc提供了解决移进-归约冲突的一般设施。在声明部分,可以为终结符指定优先级和结合性。声明 <br>
%left '+' '-' <br>
使得+和- 有同样优先级和左结合。声明 <br>
%right '^' <br>
使得算符^为右结合。还可以用声明限制两元算符为不可结合(即该算符的两个出现根本不能组合),如 <br>
%nonassoc '<'
</p>
<p>记号的优先级按它们在声明部分出现的次序而定,先出现的优先级低,同一声明中的记号有相同的优先级。这样,图4.30的声明 <br>
%right UMINUS <br>
使得UMINUS的优先级高于前面五个终结符。</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.9.2.0b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.9.2.1b.htm'"></img></td>
</tr>
</table>
</BODY>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -