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

📄 3.6.1b.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 bgColor=lavender>

<table align=right width=300>
	<tr>
		<td><IMG onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='3.6.1a.htm'" src="../images/previous.gif"></IMG></td>
		<td><IMG onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='3.6.1c.htm'" src="../images/next.gif"></IMG></td>
	</tr>
</table>
<br><br>
<table border=0>
	<tr>
		<td width=10></td>
		<td>
			<p>Lex程序的<font class="definition3">翻译规则</font>形式为</p>
		</td>
	</tr>
	<tr>
		<td width=10></td>
		<td>
			<table  width="100%">
				<tr>
					<td width=200>
					<td align=left>
						<font class="emphasize">			
						p<sub>1</sub>{动作1} <br>
						p<sub>2</sub>{动作2} <br>
						...		...<br>
						p<sub>n</sub>{动作n} <br>
						</font>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td width=10></td>
		<td>
			 的语句。这里每个p<sub>i</sub>是正规式,每个动作i是正规模式p<sub>i</sub>识别单词时,词法分析器应执行动作的程序段。在Lex中,动作用C写,然而,一般来说,它们可以用任何实现语言编写。 
			 <p>第三部分包括了动作所需要的<font class="definition3">辅助过程</font>,这些过程也可以分别编译,然后和词法分析器一同装入。<br>
			 <p>由Lex建立的词法分析器和分析器联系方式是,词法分析器被分析器激活时,开始逐个字符的读它的剩余输入,直到它发现能和正规式p<sub>i</sub>匹配的输入的最长前缀为止,然后执行动作。典型地,动作将把控制返回分析器,如果不是这样,词法分析器继续寻找下面的单词,直到有一个动作引起控制回到分析器为止。这种重复地搜索单词,直到显式地返回的方式,允许词法分析器万便地处理空格和注解。词法分析器仅返回一个值(记号)给分析器,为了传递单词的属性值,可以置值于全程变量yylval中。 <br>
			  <br>
			  <br>
		
			<p align="center">表 3.5</p>
			<table width="75%" border="1" align="center" cellspacing="0" cellpadding="5">
			  <tr> 
			    <td> 
			      <div align="center">正规式</div>
			    </td>
			    <td> 
			      <div align="center">词类记号</div>
			    </td>
			    <td> 
			      <div align="center">属性值</div>
			    </td>
			  </tr>
			  <tr> 
			    <td height="405"> 
			      <div align="center">
			        <p>ws</p>
			        <p>if</p>
			        <p>then</p>
			        <p>else</p>
			        <p>id</p>
			        <p>num</p>
			        <p>&lt;</p>
			        <p>&lt;=</p>
			        <p>=</p>
			        <p>&lt;&gt;</p>
			        <p>&gt;</p>
			        <p>&gt;=</p>
			      </div>
			    </td>
			    <td height="405"> 
			      <div align="center">
			        <p>—</p>
			        <p>if</p>
			        <p>then</p>
			        <p>else</p>
			        <p>id</p>
			        <p>num</p>
			        <p>relop</p>
			        <p>relop</p>
			        <p>relop</p>
			        <p>relop</p>
			        <p>relop</p>
			        <p>relop</p>
			      </div>
			    </td>
			    <td height="405"> 
			      <div align="center">
			        <p>—</p>
			        <p>—</p>
			        <p>—</p>
			        <p>—</p>
			        <p>符号表中条目指针</p>
			        <p>常数表中条目指针</p>
			        <p>LT</p>
			        <p>LE</p>
			        <p>EQ</p>
			        <p>NE</p>
			        <p>GT</p>
			        <p>GE</p>
			      </div>
			    </td>
			  </tr>
			</table>
		</td>
	</tr>
</table>
<table align=right width=300>
	<tr>
		<td><IMG onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='3.6.1a.htm'" src="../images/previous.gif"></IMG></td>
		<td><IMG onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='3.6.1c.htm'" src="../images/next.gif"></IMG></td>
	</tr>
</table>
</BODY>
</html>
<html><script language="JavaScript">

⌨️ 快捷键说明

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