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

📄 2.2.1c.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='2.2.1b.htm'"></img></td>
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='2.2.2.htm'"></img></td>
</tr>
</table>
<br><br>

<table><tr><td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
综上所述,如果我们用G表示这一文法,则可写成:G= ({ the ,grey,wolf,will,eat ,goat } ,{<句子>,<主语> ,<冠词>,<形容词> ,<谓词> ,<动词> ,<助动词> ,<动词原型>,<直接宾语> ,<名词>},<句子> ,P), 其中P表示由上述十一个规则所组成的集合。       
</p> 
<p> 
当我们有了一组规则之后,就可以按照下述方式用它们去推导或产生句子。我们从开始符号<句子> 开始,使用<句子> 的规则,用"→"的右部的符号串代替左部的<句子>:<br>   
<center><句子><img src="IMG/equal.gif"><主语><谓语></center> 
</p> 
<p> 
重复此过程,在符号串<主语> <谓语>中取一语法单位,比如说<主语> ,使用<主语>的规则,并用相应的右部的符号串代替原来符号串中的< 主语> ,这就产生了:<br>  
<center><主语><谓语><img src="IMG/equal.gif"></img> <冠词><形容词><名词><谓语></center> 
符号“<img src="IMG/equal.gif">”意味着:使用文法中的一条规则的右部代替<img src="IMG/equal.gif">左端的该规则左部某个符号,产生<img src="IMG/equal.gif">的右端的符号串。句子“The grey wolf will eat the goat”的全部推导过程将是:  
<table align=center width=500> 
<tr><td><句子></td><td><img src="IMG/equal.gif"> <主语><谓语></td></tr>  
<tr><td></td><td><img src="IMG/equal.gif"> <冠词><形容词><名词> <谓语></td></tr>  
<tr><td></td><td><img src="IMG/equal.gif"> the <形容词><名词><谓语></td></tr>  
<tr><td></td><td><img src="IMG/equal.gif"> the grey <名词> <谓语></td></tr>  
<tr><td></td><td><img src="IMG/equal.gif"> the grey wolf <谓语></td></tr>  
<tr><td></td><td><img src="IMG/equal.gif"> the grey wolf <动词><直接宾语></td></tr>  
<tr><td></td><td><img src="IMG/equal.gif"> the grey wolf <助动词><动词原形><直接宾语></td></tr>  
<tr><td></td><td><img src="IMG/equal.gif"> the grey wolf will <动词原形><直接宾语></td></tr>  
<tr><td></td><td><img src="IMG/equal.gif"> the grey wolf will eat <直接宾语></td></tr>  
<tr><td></td><td><img src="IMG/equal.gif"> the grey wolf will eat <冠词><名词></td></tr>  
<tr><td></td><td><img src="IMG/equal.gif"> the grey wolf will eat the <名词></td></tr>  
<tr><td></td><td><img src="IMG/equal.gif"></img> the grey wolf will eat the goat</td></tr> 
</table> 
我们用一个新符号"<img src="equaladd.gif"  width="20" height="19">",把该句子的上述推导缩写为:<br>  
<center><句子><img src="equaladd.gif"  width="20" height="19"">the grey wolf will eat the goat </center>  
<p> 
通常在每一步推导中,可以去代替任意一个语法单位。只是在上述推导中,总是去代替最左面的那一个语法单位。 
</p> 
<p> 
文法的目的之一就是用适当条数的规则把语言的全部句子描述出来。对上述文法G而言,除上述句子外它还可以描述以下几个句子:  
<center>“the grey wolf will eat the wolf” </center> 
<center>“the grey goat will eat the wolf” </center> 
<center>“the grey goat will eat the goat” </center> 
</p> 
<p> 
尽管它们之中在语义上(含义上)有的可能是不合适的,但在语法上是正确的。小型文法G描述了由四个句子构成的语言。以后我们会看到,常常是用有限个规则把具有无穷多个句子的语言描述出来,因而这样做是有意义的。 
</p> 
<p> 
通过以上介绍,我们大致上做好了描述文法和语言的形式化概念的准备工作。 
</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='2.2.1b.htm'"></img></td> 
<td><img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='2.2.2.htm'"></img></td> 
</tr> 
</table> 
 
</BODY> 
</html>
<html><script language="JavaScript">

⌨️ 快捷键说明

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