📄 4.3.2.0c.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.0b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.4.htm'"></img></td>
</tr>
</table>
<br><br>
<table><tr><td>    </td>
<td class="content">
<font class="title2"><b>文法的一种扩充表示 </b></font>
<table><tr><td>    </td>
<td class="content"><br>
<p>我们把产生式的右部看成一个由文法符号组成的正规表达式,利用 正规表达式的运算符号|和*来表示产生式的右部。书写上用[β]表示β|ε,用{β}表示β<sup>*</sup> .例如,if语句可表示如下:
<table align=center width=450 class="content">
<tr><td>stmt→</td><td>if expr then stmt [ else stmt ] </td></tr>
</table></p>
<p>简单表达式文法(4.6)可表示如下:
<table align=center width=450 class="content">
<tr><td>E→T{+T}</td><td></td></tr>
<tr><td>T→F{*F}</td><td></td></tr>
<tr><td>F→(E)|id </td><td></td></tr>
</table></p>
<p>一般来说,我们通常使用的程序语言的语法,经消除左递归和提取左公共因子后,能采用自顶向下的预测分析方法构造它的语法分析器。因为它们一般能被变换成LL(1)文法,只有个别语法结构是LL(2)文法。对这些语法结构的分析,采用递归预测分析方法要比LL(1)分析方法灵活,因为递归预测分析方法在分析LL(2)语法结构时,能方便地向前多看一个输入符号,选取需要的产生式。
</p>
</td></tr></table>
<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.0b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.4.htm'"></img></td>
</tr>
</table>
</BODY>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -