📄 3.2.2b.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 bgColor=Lavender>
<table align=right width=300>
<tr>
<td><IMG onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='3.2.2.htm'" src="../images/previous.gif"></td>
<td><IMG onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='3.2.3.htm'" src="../images/next.gif"></td>
</tr>
</table>
<br><br>
<table border=0>
<tr>
<td width=5></td>
<td colspan=2>
<br>
<b>3.2.2 构造识别单词的DFA</b><br><br>
</td>
</tr>
<tr>
<td width=10></td>
<td width=30></td>
<td>
<p>通过以上讨论,我们知道了一个非常重要的事实,即<font class="emphasize">大多程序语言的单词都可以用DFA M予以识别</font>。我们来构造一个识别某个简单语言的所有单词符号的DFA
M。表3.1列出了这个语言的所有单词符号,以及它们的种别和属性值。图3.4是相应的状态转换图。</p>
<p>这里,我们假定所有关键字(如begin,end,if等等)都是保留字,即用户不得使用它们作为自己定义的标识符。这样就可以把关键字作为一类特殊的标识符来处理,不再专设对应的转换图。因而预先要把所有的关键字安排在一个表格中,此表叫做保留字表。当利用图3.4识别出一个标识符时,就去查对保留字表,确定它是否是一个保留字。 <br>
其次假定,若关键字、标识符和常数之间没有确定的运算符或分界符做间隔的话,那么必须至少用一个空白符做间隔,即此时空白符是有意义的。</p>
<p>状态转换图3.4以状态0为初态;图中凡带双圈者均为终态;状态21是出错情况,此情况下识别不出合法的单词。</p>
<center><img src="img/3.4.gif" ><br><br>
</center>
</td>
</tr>
</table>
<table align=right width=300>
<tr>
<td><IMG onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='3.2.2.htm'" src="../images/previous.gif"></td>
<td><IMG onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='3.2.3.htm'" src="../images/next.gif"></td>
</tr>
</table>
</BODY>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -