⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 4.2.2.1.htm

📁 建立《编译原理网络课程》的目的不仅使学生掌握构造编译程序的原理和技术
💻 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.2.2.0b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.2.2.1b.htm'"></img></td>
</tr>
</table>
<br><br>
<p>    
<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>      
<td class="content">      
 
<p><font class="emphasize">  
使用转换图构造递归预测分析器</font></p>      
<p>  
在构造分析器的过程中,我们用正规表达式描述单词结构模式,把它变成有限自动机,作为编写词法分析器的蓝图;现在,我们可以把每个产生式右部看成V<sub>T</sub>∪V<sub>N</sub>上的正规表达式,由此画出相应的识别器,称作状态转换图,以此作为编写递归预测分析器的蓝图。对于给定的一个上下文无关文法,其状态转换图的构造方法相当简单,对于每个非终结符A作下面的工作:</p>      
  
<p>  
1.创建一个初始状态和一个终结状态。</p>      
  
<p>  
2.对于每一个产生式A →X<sub>1</sub>X<sub>2</sub>…,X<sub>n</sub>,创建一条从初始状态到终结状态的路径,箭弧分别标志以X<sub>1</sub>,X<sub>2</sub>,…,X<sub>n</sub>。</p>      
<hr size=2 width=90% align=center color=red><br>  
<p>  
<font class="example">例4.3 </font>  
根据文法(4.3)的各个产生式,可以得到如图4.4所表示的文法(4.3)的一组转换图;其中画双圈者表示终态。E的初态是0,终态是2;E'的初态是3,终态是6;等等。</p>      
  
<p>  
G[E]=(V<sub>T</sub>={+,*,(,),id} V<sub>N</sub>={E,E',T,T',F},E,P}<br>  
&nbsp;&nbsp;&nbsp;&nbsp;P:<br>  
&nbsp;&nbsp;&nbsp;&nbsp;E→TE'<br>  
&nbsp;&nbsp;&nbsp;&nbsp;E'→+TE'|ε<br>  
&nbsp;&nbsp;&nbsp;&nbsp;T→FT'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(4.3)<br>  
&nbsp;&nbsp;&nbsp;&nbsp;T'→*FT'|ε<br>  
&nbsp;&nbsp;&nbsp;&nbsp;F→(E)|id  
</p>      
</td></tr></table>    
  
<p>      
<center><img src="images/4.4.gif" width="350" height="321"></center><br>  
<center class="content">图4.4 文法4.3的转换图</p>   
<br>       
<table align=right width=300>       
<tr>       
<td><img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.2.2.0b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='4.2.2.1b.htm'"></img></td>
</tr>       
</table>       
       
</BODY>       
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -